def on_app_filter_search_changed(self, widget, data=None): if self.updating_subcategories: return user_filter = self.app_filter.get_text().lower() if not user_filter: # Refresh apps self.preconfig_app.remove_all() apps = self.apps.get_apps_cat_subcat(self.preconfig_category.get_active_text(), self.preconfig_subcategory.get_active_text()) for app in apps: self.preconfig_app.append_text(app) self.preconfig_app.set_active(0) self.app_filter.modify_fg(Gtk.StateFlags.NORMAL, None) return # Apps new_apps = [] apps = self.apps.get_apps_cat_subcat(self.preconfig_category.get_active_text(), self.preconfig_subcategory.get_active_text()) for app in apps: if (app.lower().find(user_filter) != -1 or # Search in name self.apps.get_app(app)[0].lower().find(user_filter) != -1 or # Search in description self.apps.get_app(app)[1].lower().find(user_filter) != -1): # Search in ports if new_apps.count(app) == 0: new_apps.append(app) if len(new_apps) > 0: self.preconfig_app.remove_all() for app in new_apps: self.preconfig_app.append_text(app) self.preconfig_app.set_active(0) self.app_filter.modify_fg(Gtk.StateFlags.NORMAL, None) else: self.app_filter.modify_fg(Gtk.StateFlags.NORMAL, Color(50000, 0, 0))
def on_login_clicked(self, button, false=None): username = self.builder.get_object('username').get_text() password = self.builder.get_object('password').get_text() voting_id = self.builder.get_object('votingId').get_text() COLOR_INVALID = Color(50000, 0, 0) self.builder.get_object('usernameLabelError').modify_fg( Gtk.StateFlags.NORMAL, COLOR_INVALID) self.builder.get_object('passwordLabelError').modify_fg( Gtk.StateFlags.NORMAL, COLOR_INVALID) self.builder.get_object('votingIdLabelError').modify_fg( Gtk.StateFlags.NORMAL, COLOR_INVALID) if not username: self.builder.get_object('usernameLabelError').set_text( "Empty Username") else: self.builder.get_object('usernameLabelError').set_text("") if not password: self.builder.get_object('passwordLabelError').set_text( "Empty Password") else: self.builder.get_object('passwordLabelError').set_text("") if not voting_id: self.builder.get_object('votingIdLabelError').set_text( "Must insert voting identifier") else: self.builder.get_object('votingIdLabelError').set_text("") if password and username and voting_id and voting_id: self.cur.execute( "SELECT id, username, password from public.auth_user where username = %s", [username]) user = self.cur.fetchone() if not user: print("User not found") self.builder.get_object('usernameLabelError').set_text( "Invalid user or password") else: cryptedPassword = user[2] passOk = django.contrib.auth.hashers.check_password( password, cryptedPassword) check_voting_access = self.check_voting_access(user, voting_id) check_already_voted = self.check_already_voted(user, voting_id) if passOk and check_voting_access and check_already_voted == False: print("Correct user") user_token = user[0] print("User token " + str(user_token)) self.voting(user, voting_id) elif passOk: self.builder.get_object('votingIdLabelError').set_text( "You don't have access to the voting") else: print("Invalid password") self.builder.get_object('usernameLabelError').set_text( "Invalid user or password")
def on_entry1(entry): # [email protected] checks['email'] = check_email(entry.get_text()) if checks['email']: entry1.modify_fg(Gtk.StateFlags.NORMAL, None) else: entry1.modify_fg(Gtk.StateFlags.NORMAL, Color(50000, 0, 0)) check_all()
def _strip_text(self, widget): widget.modify_fg(Gtk.StateFlags.NORMAL, None) text = widget.get_text().strip() filtered_text = (''.join([i for i in text if i in '0123456789.'])) widget.set_text(filtered_text) try: price = float(filtered_text) except ValueError: widget.modify_fg(Gtk.StateFlags.NORMAL, Color(50000, 0, 0))
def on_entry1(entry): # "RWCN-94NV-CEHR" -> ("RWCN", "94NV", "CEHR") | None vaction_code = parse_activation_code(entry.get_text()) if vaction_code: entry1.modify_fg(Gtk.StateFlags.NORMAL, None) button1.set_sensitive(True) else: entry1.modify_fg(Gtk.StateFlags.NORMAL, Color(50000, 0, 0)) button1.set_sensitive(False)
def on_shortcut_entry_changed(self, widget): text = widget.get_text().upper() widget.set_text(text) if (text >= 'A' and text <= 'Z') or (text >= '0' and text <= '9'): widget.modify_fg(Gtk.StateFlags.NORMAL, None) MetaData.set_snapshoot_shortcut_value(text) logging.debug(MetaData.get_snapshoot_shortcut()) SettingDialog.KeyBinder.bind_key() else: COLOR_INVALID = Color(50000, 0, 0) widget.modify_fg(Gtk.StateFlags.NORMAL, COLOR_INVALID)
def tablaFinal(self, matrizfs, islas=None): # elimina grid si hay una while self.scrolled.get_child() is not None: self.scrolled.remove(self.scrolled.get_child()) grid = Gtk.Grid() self.scrolled.add_with_viewport(grid) #establece tamanio del grid dim = matrizfs.shape filas = dim[0] columnas = dim[1] #en esta variable van a estar las celdas que se colorean colorear = list() #determinar las celdas que se colorean if self.algoritmoNW: colorear = self.colorear_celda(matrizfs, filas - 1, columnas - 1) else: for isla in islas: lista = self.colorear_celda(matrizfs, isla[0], isla[1]) colorear.extend(lista.copy()) celdasTabla = {} rgba = RGBA() rgba.parse("#7f7f7f") rgba.to_string() #llenar celdas for i in range(filas): for j in range(columnas): if isinstance(matrizfs[i][j], str): celdasTabla["c9999{0},{1}".format(i, j)] = Gtk.Label() celdasTabla["c9999{0},{1}".format(i, j)].set_text( matrizfs[i][j]) if "c9999{0},{1}".format(i, j) in colorear: celdasTabla["c9999{0},{1}".format(i, j)].modify_fg( Gtk.StateFlags.NORMAL, Color(50000, 0, 0)) else: celdasTabla["c9999{0},{1}".format(i, j)] = Gtk.Entry() celdasTabla["c9999{0},{1}".format(i, j)].set_property( "editable", False) celdasTabla["c9999{0},{1}".format(i, j)].set_text( str(matrizfs[i][j])) if "c9999{0},{1}".format(i, j) in colorear: celdasTabla["c9999{0},{1}".format( i, j)].override_background_color( Gtk.StateFlags.NORMAL, rgba) grid.attach(celdasTabla["c9999{0},{1}".format(i, j)], j, i, 1, 1) grid.show_all()
def on_entry23(_): pw1_ok = False if check_password(entry2.get_text()): pw1_ok = True entry2.modify_fg(Gtk.StateFlags.NORMAL, None) else: entry2.modify_fg(Gtk.StateFlags.NORMAL, Color(50000, 0, 0)) pw2_ok = False if check_password(entry3.get_text()): pw2_ok = True entry3.modify_fg(Gtk.StateFlags.NORMAL, None) else: entry3.modify_fg(Gtk.StateFlags.NORMAL, Color(50000, 0, 0)) if pw1_ok and pw2_ok and entry2.get_text() == entry3.get_text() and check_password(entry2.get_text()): checks['password'] = entry2.get_text() else: checks['password'] = None check_all()
def __init__(self, req, vmanager): self.req = req self.config = self.req.get_config('browser') builder = Gtk.Builder() builder.add_from_file(ViewConfig.PREFERENCES_UI_FILE) self.dialog = builder.get_object("PreferencesDialog") self.dialog.set_title(_("Preferences - %s" % info.NAME)) self.pref_autostart = builder.get_object("pref_autostart") self.pref_show_preview = builder.get_object("pref_show_preview") self.bg_color_enable = builder.get_object("bg_color_enable") self.hbox1 = builder.get_object("hbox1") self.shortcut_button = builder.get_object("shortcut_button") self.shortcut = ShortcutWidget(builder) help.add_help_shortcut(self.dialog, "preferences") self.fontbutton = builder.get_object("fontbutton") self.timer = vmanager.timer self.color_invalid = Color(50000, 0, 0) self.refresh_hour = builder.get_object("hour") self.refresh_mins = builder.get_object("min") editor_font = self.config.get("font_name") if editor_font == "": font = self.dialog.get_style_context().get_font( Gtk.StateFlags.NORMAL) editor_font = font.to_string() self.fontbutton.set_font_name(editor_font) builder.connect_signals({ 'on_pref_autostart_toggled': self.on_autostart_toggled, 'on_pref_show_preview_toggled': self.toggle_preview, 'on_bg_color_toggled': self.on_bg_color_toggled, 'on_prefs_help': self.on_help, 'on_prefs_close': self.on_close, 'on_PreferencesDialog_delete_event': self.on_close, 'on_fontbutton_font_set': self.on_font_change, 'on_shortcut_button_toggled': self.shortcut.on_shortcut_toggled, 'on_valid_check': self.valid_check, })
def signInButtonClicked(self, *args): COLOR_INVALID = Color(50000, 10000, 10000) email = self.login_window.email_field.get_text() password = self.login_window.password_field.get_text() result = re.match( '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', email) if result is None: self.login_window.email_field.modify_fg( Gtk.StateFlags.NORMAL, COLOR_INVALID) return else: self.login_window.email_field.modify_fg( Gtk.StateFlags.NORMAL, None) self.login_window.spinner.start() try: result = is_valid(email, password) if result: self.login_window.spinner.stop() self.login_window.show_successful_login_dialog() config['usage_mode'] = 'authenticated' config['login_credentials']['email'] = email config['login_credentials']['password'] = password else: self.login_window.spinner.stop() self.login_window.show_failed_login_dialog() config['usage_mode'] = 'anonymous' except ConnectionError: self.login_window.spinner.stop() self.login_window.show_connection_error_dialog() finally: self.login_window.spinner.stop()
class FlowGuiNode(GFlow.SimpleNode): #COLOR_INVALID = Gdk.RGBA(255,0,0) COLOR_INVALID = Color(50000, 0, 0) def __new__(cls, *args, **kwargs): x = GFlow.SimpleNode.new() x.__class__ = cls return x def __init__(self, procNode): self.procNode = procNode self.setPorts([p for p in procNode.inputPorts.keys()], [p for p in procNode.outputPorts.keys()]) self.setParams(procNode.getParams()) self.set_name(procNode.name) self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) label = Gtk.Label.new(procNode.name) self.vbox.pack_start(label, False, False, 0) self.generateParamBox() def __del__(self): logger.critical('DTOR not implemented!') def generateParamBox(self): if len(self.procNode.getParams()) == 0: return sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL) self.vbox.pack_start(sep, False, False, 0) self.expander = Gtk.Expander.new('Parameters') self.expander.set_resize_toplevel(True) self.paramBox = Gtk.ListBox() for k, v in self.procNode.getParams().items(): hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0) label = Gtk.Label(k) label.set_xalign(0) hbox.pack_start(label, True, True, 0) entry = Gtk.Entry() entry.set_text(str(v)) entry.set_alignment(1) entry.set_has_frame(False) entry.connect('changed', lambda w, d=None, key=k: self.__paramChanged(w, key)) hbox.pack_start(entry, True, True, 0) row = Gtk.ListBoxRow() row.add(hbox) self.paramBox.add(row) self.expander.add(self.paramBox) self.vbox.pack_end(self.expander, True, True, 0) def setPorts(self, ins, outs): for i in ins: sink = GFlow.SimpleSink.new("") sink.set_name(i) self.add_sink(sink) for o in outs: source = GFlow.SimpleSource.new("") source.set_name(o) source.set_valid() source.connect("linked", self.__sourceLinked) source.connect("unlinked", self.__sourceUnlinked) self.add_source(source) def setParams(self, paramDict): pass def __paramChanged(self, gtkEntry, key): valStr = gtkEntry.get_text() try: val = type(self.procNode.getParam(key))(valStr) if self.procNode.setParam(key, val): logger.debug('Changing parameter "%s" to value "%s"', key, val) else: logger.error('Failed to change parameter "%s" to value "%s"', key, val) #gtkEntry.modify_base(Gtk.StateFlags.NORMAL, None) except (TypeError, ValueError) as e: #gtkEntry.modify_base(Gtk.StateType.GTK_STATE_NORMAL, FlowGuiNode.COLOR_INVALID) logger.error('Incompatible type for parameter "%s" (must be %s)', key, str(type(self.procNode.getParam(key)))) def __sourceLinked(self, sourceDock, sinkDock): sinkName = sinkDock.get_name() sinkNode = sinkDock.get_node().procNode sourceName = sourceDock.get_name() sourceNode = sourceDock.get_node().procNode #print("%s:%s linked to %s:%s" % (sourceNode.name, sourceName, sinkNode.name, sinkName)) sinkPort = sinkNode.inputPorts[sinkName] sourcePort = sourceNode.outputPorts[sourceName] self.procNode.connectPorts(sourcePort, sinkPort) def __sourceUnlinked(self, sourceDock, sinkDock): sinkName = sinkDock.get_name() sinkNode = sinkDock.get_node().procNode sinkPort = sinkNode.inputPorts[sinkName] sourceName = sourceDock.get_name() sourceNode = sourceDock.get_node().procNode sourcePort = sourceNode.outputPorts[sourceName] self.procNode.disconnectPorts(sourcePort, sinkPort)