mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-19 09:51:19 +02:00
GTK fixes
This commit is contained in:
parent
215a1dbc2f
commit
db3a8cbfd4
4 changed files with 27 additions and 20 deletions
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 44 KiB |
|
@ -68,27 +68,30 @@ def on_model_add(self, button):
|
|||
dialog.destroy()
|
||||
|
||||
if response == gtk.ResponseType.OK:
|
||||
dialog = gtk.MessageDialog(parent=self, flags=gtk.DialogFlags.MODAL)
|
||||
dialog = gtk.MessageDialog(parent=self, flags=gtk.DialogFlags.MODAL, buttons=gtk.ButtonsType.NONE)
|
||||
dialog.set_title(_("Creating Model"))
|
||||
dialog.props.text = _("Please look directly into the camera")
|
||||
dialog.get_child().connect("map", lambda w: execute_add(self, dialog, entered_name, self.active_user))
|
||||
dialog.show_all()
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
status, output = subprocess.getstatusoutput(["howdy add -y -U " + self.active_user + " '" + entered_name + "'"])
|
||||
def execute_add(box, dialog, entered_name, user):
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
status, output = subprocess.getstatusoutput(["howdy add '" + entered_name + "' -y -U " + box.active_user])
|
||||
|
||||
dialog.destroy()
|
||||
|
||||
if status != 0:
|
||||
dialog = gtk.MessageDialog(parent=box, flags=gtk.DialogFlags.MODAL, type=gtk.MessageType.ERROR, buttons=gtk.ButtonsType.CLOSE)
|
||||
dialog.set_title(_("Howdy Error"))
|
||||
dialog.props.text = _("Error while adding model, error code {}: \n\n").format(str(status))
|
||||
dialog.format_secondary_text(output)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
if status != 0:
|
||||
dialog = gtk.MessageDialog(parent=self, flags=gtk.DialogFlags.MODAL, type=gtk.MessageType.ERROR, buttons=gtk.ButtonsType.CLOSE)
|
||||
dialog.set_title(_("Howdy Error"))
|
||||
dialog.props.text = _("Error while adding model, error code {}: \n\n").format(str(status))
|
||||
dialog.format_secondary_text(output)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
self.load_model_list()
|
||||
|
||||
box.load_model_list()
|
||||
|
||||
def on_model_delete(self, button):
|
||||
selection = self.treeview.get_selection()
|
||||
|
|
|
@ -71,10 +71,12 @@ class MainWindow(gtk.Window):
|
|||
def load_model_list(self):
|
||||
"""(Re)load the model list"""
|
||||
|
||||
# Get username and default to none if there are no models at all yet
|
||||
user = 'none'
|
||||
if self.active_user: user = self.active_user
|
||||
|
||||
# Execute the list commond to get the models
|
||||
# status, output = subprocess.getstatusoutput(["howdy list --plain -U " + self.active_user])
|
||||
status = 0
|
||||
output = "1,2020-12-05 14:10:22,sd\n2,2020-12-05 14:22:41,\n3,2020-12-05 14:57:37,Model #3" + self.active_user
|
||||
status, output = subprocess.getstatusoutput(["howdy list --plain -U " + user])
|
||||
|
||||
# Create a datamodel
|
||||
self.listmodel = gtk.ListStore(str, str, str)
|
||||
|
@ -82,12 +84,13 @@ class MainWindow(gtk.Window):
|
|||
# If there was no error
|
||||
if status == 0:
|
||||
# Split the output per line
|
||||
# lines = output.decode("utf-8").split("\n")
|
||||
lines = output.split("\n")
|
||||
|
||||
# Add the models to the datamodel
|
||||
for i in range(len(lines)):
|
||||
self.listmodel.append(lines[i].split(","))
|
||||
items = lines[i].split(",")
|
||||
if len(items) < 3: continue
|
||||
self.listmodel.append(items)
|
||||
|
||||
self.treeview.set_model(self.listmodel)
|
||||
|
||||
|
|
|
@ -26,8 +26,9 @@ enc_file = path + "/models/" + user + ".dat"
|
|||
try:
|
||||
encodings = json.load(open(enc_file))
|
||||
except FileNotFoundError:
|
||||
print(_("No face model known for the user {}, please run:").format(user))
|
||||
print("\n\tsudo howdy -U " + user + " add\n")
|
||||
if not builtins.howdy_args.plain:
|
||||
print(_("No face model known for the user {}, please run:").format(user))
|
||||
print("\n\tsudo howdy -U " + user + " add\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Print a header if we're not in plain mode
|
||||
|
|
Loading…
Reference in a new issue