def __init__(self, title=_("Enter Price"), text=_("Choose a Price:"), default_value=0, min_value=-1000000000, max_value=1000000000, step=1): """Creates a DecimalPrompt arguments: title - a string to be the title of the dialog text - a string to provide a prompt for the user within dialog default_value - an integer to display by default, should be greater than keywrod arguments: keyword arguments: the min_value and less then the max_value min_value - the lowest number accepted by the spinner, defaults to -1000000000 max_value, the highest number accepted by the spinner, defaults to 1000000000 step - set the incriments for each click of the spinner buttons, defaults to 1 returns a tuple of (Gtk.DialogResponse, number) Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog (Gtk.ResponseType.DELETE_EVENT) """ DecimalPrompt.__init__(self,title,text,default_value,min_value, max_value, step) self._spinner.set_digits(2)
def price(title=_("Enter Price"), text=_("Choose a Price:"), default_value=0, min_value=-1000000000, max_value=1000000000, step=1): """price - prompts to enter a number up to the hundreths place using a spinner via a dialog box. aguments: title - a string to be the title of the dialog text - a string to provide a prompt for the user within dialog default_value - an integer to display by default, should be greater than keyword arguments: the min_value and less then the max_value min_value - the lowest number accepted by the spinner, defaults to -1000000000 max_value, the highest number accepted by the spinner, defaults to 1000000000 step - set the incriments for each click of the spinner buttons, defaults to 1 returns a tuple of (Gtk.DialogResponse, number) Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog (Gtk.ResponseType.DELETE_EVENT) """ pp = PricePrompt(title, text, default_value, min_value, max_value, step) response = pp.run() val = pp.get_value() pp.destroy() return (response, val)
def __init__(self, allTables): chooseWindows.__init__(self) self.singleBiblio = SingleBiblio.SingleBiblio(allTables) self.loadGlade('biblio.xml', 'BiblioMainwindow') #self.win1 = self.getWidget('BiblioMainwindow') #self.setStatusBar() self.allTables = allTables self.EntriesBiblio = 'biblio.xml' self.loadEntries(self.EntriesBiblio) self.singleBiblio.setEntries(self.getDataEntries('biblio.xml') ) self.singleBiblio.setGladeXml(self.xml) self.singleBiblio.setTreeFields( ['title', 'designation','year','month'] ) self.singleBiblio.setStore( gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT, gobject.TYPE_UINT, gobject.TYPE_UINT) ) self.singleBiblio.setTreeOrder('title,year,month') self.singleBiblio.setListHeader([_('Title'), _('Designation'), _('Year'),_('Month')]) self.singleBiblio.setTree(self.getWidget('tree1') ) # set values for comboBox # Menu-items self.initMenuItems() # Close Menus for Tab self.addEnabledMenuItems('tabs','mi_biblio1') # seperate Menus self.addEnabledMenuItems('biblio','mi_biblio1') # enabledMenues for Address self.addEnabledMenuItems('editBiblio','mi_new1') self.addEnabledMenuItems('editBiblio','mi_clear1') self.addEnabledMenuItems('editBiblio','mi_print1') self.addEnabledMenuItems('editBiblio','mi_edit1') # tabs from notebook self.tabBiblio = 0 self.tabChanged()
def set_locked_state(self, locked): """Change the locked state of the stickynote""" self.locked = locked self.txtNote.set_editable(not self.locked) self.txtNote.set_cursor_visible(not self.locked) self.bLock.set_image({True: self.imgLock, False: self.imgUnlock}[self.locked]) self.bLock.set_tooltip_text({True: _("Unlock"), False: _("Lock")}[self.locked])
def miImportRDP_activate(self, widget): fcd = Gtk.FileChooserDialog(title = _('Select RDP file to import'), buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) ff = Gtk.FileFilter() ff.set_name(_('Windows Remote Desktop files')) ff.add_pattern('*.rdp') fcd.add_filter(ff) response = fcd.run() rdpfile = fcd.get_filename() fcd.destroy() if rdpfile is None: return lAppNames = [] for row in self.ui.lsApps: lAppNames.append(row[0]) if self.common.importRDP(lAppNames, rdpfile): self.common.setApp() self.ui.lsApps.append(self.common.get_App_opt()) self.indicator.rebuild_menu(self) self.ui.lStatus.set_text(_('RDP import succeessful')) else: self.ui.lStatus.set_text(_('RDP import unsuccessful'))
def check_change(self): if self.data.running_status == Resource.STATUS_STOPPED: self.data.status_code = _(u'STOPPED') self.data.source_id = None self.emit('checked') return False fp = self._open_resource() if fp is None: # if we don't have hash value set, then we have a status error, so # we don't need to check the file content. self.emit('checked') return bool(self.data.hash_value) hash_value = self._generate_hash_value(fp) self.data.status_code = _(u'RUNNING') fp.close() if not self.data.hash_value: self.data.hash_value = hash_value if self.data.hash_value == hash_value: self.data.status_description = _(u'OK') else: self.data.hash_value = '' self.data.status_code = _(u'STOPPED') self.data.status_description = _(u'CHANGED') self.data.running_status = Resource.STATUS_STOPPED self.data.source_id = None self.emit('checked') return False self.emit('checked') return True
def check_change(self): if self.did_change and len(self.get_text()): dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.WARNING, None, _("You have not saved your changes.") ) dialog.add_button(_("Close without Saving"), Gtk.ResponseType.NO) dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("Save now"), Gtk.ResponseType.YES).grab_focus() dialog.set_title(_('Unsaved changes')) dialog.set_default_size(200, 150) response = dialog.run() if response == Gtk.ResponseType.YES: title = self.get_title() if self.save_document(widget = None) == Gtk.ResponseType.CANCEL: dialog.destroy() return self.check_change() else: dialog.destroy() return response elif response == Gtk.ResponseType.CANCEL: dialog.destroy() return response elif response == Gtk.ResponseType.NO: dialog.destroy() return response
def on_bg_combobox_format(self, combobox, path): model, rowiter = self._widgets.selection.get_selected() item_type = combobox.props.model[path][BackgroundRow.Type] value = model[rowiter][Row.Background] if item_type == 'path': if not self._file_dialog: self._file_dialog = Gtk.FileChooserDialog( parent=self, buttons=(_('_OK'), Gtk.ResponseType.OK, _('_Cancel'), Gtk.ResponseType.CANCEL), title=C_('option|multihead', 'Select background file')) self._file_dialog.props.filter = Gtk.FileFilter() self._file_dialog.props.filter.add_mime_type('image/*') if self._file_dialog.run() == Gtk.ResponseType.OK: value = self._file_dialog.get_filename() self._file_dialog.hide() elif item_type == 'color': if not self._color_dialog: self._color_dialog = Gtk.ColorChooserDialog(parent=self) if self._color_dialog.run() == Gtk.ResponseType.OK: value = self._color_dialog.get_rgba().to_color().to_string() self._color_dialog.hide() else: value = '' combobox.set_active(-1) return value
def cancel(self): if self.IPTVInstalled is True: infobox = self.session.open(MessageBox,_("Reloading Bouquets and Services..."), MessageBox.TYPE_INFO, timeout=5) infobox.setTitle(_("Info")) eDVBDB.getInstance().reloadBouquets() eDVBDB.getInstance().reloadServicelist() self.close()
def __init__(self): self.dicReportData = {} self.dicReportData['Title'] = _('Cashaccountbook ') self.dicReportData['lPageNumber'] = _('Pagenumber:') self.dicReportData['fPageNumber'] = 1
def package(self): data_obj = data.Data() path = data_obj.get_work_path() # Also search for dependency binaries and libraries next to myself dependenciesdir = path + "/usr/" os.environ['PATH'] = dependenciesdir + "/bin:" + os.getenv('PATH') # print os.environ['PATH'] lddp = os.getenv('LD_LIBRARY_PATH') if lddp == None: lddp = "" os.environ['LD_LIBRARY_PATH'] = dependenciesdir + "/lib:" + lddp sourcedir = path destinationfile = data_obj.get_out_path() should_compress = True if should_compress == True: if not os.path.exists(sourcedir): print("Application work directory not found: %s" % (sourcedir)) exit(1) if should_compress == True: H = xdgappdir.AppDirXdgHandler(sourcedir) iconfile = H.get_icon_path_by_icon_name(H.get_icon_name_from_desktop_file(H.desktopfile)) if iconfile == None: print("Icon could not be found based on information in desktop file") #exit(1) print("Creating %s..." % (destinationfile)) if os.path.exists(destinationfile): print (_("Destination path already exists, exiting")) # xorriso would append another session to a pre-existing image exit(1) # As great as xorriso is, as cryptic its usage is :-( command = ["xorriso", "-joliet", "on", "-volid", "AppImage", "-dev", destinationfile, "-padding", "0", "-map", sourcedir, "/", "--", "-map", iconfile, "/.DirIcon", "-zisofs", "level=9:block_size=128k:by_magic=off", "-chown_r", "0", "/", "--", "set_filter_r", "--zisofs", "/" ] subprocess.Popen(command).communicate() print("ok") print("Embedding runtime...") elf = os.path.realpath(os.path.dirname(__file__)) + "/runtime" s = open(elf, 'rb') f = open(destinationfile, 'rb+') f.write(bytes(s.read())) f.close() s.close() print("ok") print("Making %s executable..." % (destinationfile)) os.chmod(destinationfile, 0o755) print("ok") filesize = int(os.stat(destinationfile).st_size) print (_("Size: %f MB") % (filesize/1024/1024))
def open_document(self, widget): if self.check_change() == Gtk.ResponseType.CANCEL: return filefilter = Gtk.FileFilter.new() filefilter.add_mime_type('text/x-markdown') filefilter.add_mime_type('text/plain') filefilter.set_name(_('MarkDown or Plain Text')) filechooser = Gtk.FileChooserDialog( _("Open a .md-File"), self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK) ) filechooser.add_filter(filefilter) response = filechooser.run() if response == Gtk.ResponseType.OK: filename = filechooser.get_filename() self.load_file(filename) filechooser.destroy() elif response == Gtk.ResponseType.CANCEL: filechooser.destroy()
def __init__(self, allTables): chooseWindows.__init__(self) self.singleClient = SingleClient.SingleClient(allTables) self.loadGlade('address.xml') self.win1 = self.getWidget('AddressMainwindow') self.setStatusBar() self.EntriesAddresses = 'addresses.xml' self.loadEntries(self.EntriesAddresses) self.singleAddress.setEntries(self.getDataEntries('addresses.xml') ) self.singleAddress.setGladeXml(self.xml) self.singleAddress.setTreeFields( ['lastname', 'firstname','city'] ) self.singleAddress.setStore( gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT) ) self.singleAddress.setTreeOrder('lastname, firstname') self.singleAddress.setListHeader([_('Lastname'), _('Firstname'), _('City')]) self.singleAddress.setTree(self.xml.get_widget('tree1') ) # set values for comboBox # Menu-items self.initMenuItems() # Close Menus for Tab self.addEnabledMenuItems('tabs','mi_address1') # seperate Menus self.addEnabledMenuItems('address','mi_address1') # enabledMenues for Address self.addEnabledMenuItems('editAddress','mi_new1') self.addEnabledMenuItems('editAddress','mi_clear1') self.addEnabledMenuItems('editAddress','mi_print1') self.addEnabledMenuItems('editAddress','mi_edit1') # tabs from notebook self.tabClients = 0 self.tabChanged()
def sendBugReport(self): errorMessage = None infoMessage = None if not self.isAPIKeyValid(): raise BugReporterException(_("Please verify your API key.")) # Compute the content of the report reportContent = self.getReportContent() # Verify if its a duplicated report idDuplicateIssue = self.getIssueWithContent(reportContent) if idDuplicateIssue is not None: if idDuplicateIssue > 0: # Found a duplicated issue, we register the user as a watcher self.log.info("Bug already reported but we register you on it") registerErrorMessage = self.registerUserOnIssue(idDuplicateIssue) if registerErrorMessage is None: infoMessage = _("You've been associated to the bug report {0}/issues/{1}.".format(BugReporter.URL_TARGET_BUG_REPORT, idDuplicateIssue)) else: self.log.error(registerErrorMessage) errorMessage = _("An error occurred while you were associated with the bug report {0}/issues/{1}.".format(BugReporter.URL_TARGET_BUG_REPORT, idDuplicateIssue)) raise BugReporterException(errorMessage) else: infoMessage = "You have already reported this bug." else: self.log.debug("This bug has never been reported yet.") errorMessage = self.publishReport(reportContent) if errorMessage is None: idDuplicateIssue = self.getIssueWithContent(reportContent) infoMessage = _("The bug report has successfully been published on {0}/issues/{1}".format(BugReporter.URL_TARGET_BUG_REPORT, idDuplicateIssue)) # Everything went fine, we can return the successfull message. return infoMessage
def refresh_title(self, *args): """Updates the title of the category""" name = self.noteset.categories[self.cat].get("name", _("New Category")) if self.noteset.properties.get("default_cat", "") == self.cat: name += " (" + _("Default Category") + ")" self.lExp.set_text(name)
def run(self): self.terminal.select_all() self.terminal.copy_clipboard() self.terminal.unselect_all() clipboard = Gtk.Clipboard.get_default(self.parent_window.get_display()) selection = clipboard.wait_for_text() if not selection: return selection = selection.rstrip() filter = Gtk.FileFilter() filter.set_name(_("All files")) filter.add_pattern("*") self.add_filter(filter) filter = Gtk.FileFilter() filter.set_name(_("Text and Logs")) filter.add_pattern("*.log") filter.add_pattern("*.txt") self.add_filter(filter) response = super().run() if response == Gtk.ResponseType.OK: filename = self.get_filename() with open(filename, "w") as f: f.write(selection) self.destroy()
def on_directions_clicked(self, widget, fromfield, tofield, resultview, marker_layer, directionlist): if fromfield.marker and tofield.marker: # do directions lookup guide = Guide(self.application, marker_layer, directionlist.get_model()) error = guide.search(fromfield.get_marker(), tofield.get_marker()) if not error: marker_layer.show() resultview.show(_("Directions"), 1) # 1 -> show directions directionlist.show() else: resultview.show(error, 1) # 1 -> show directions else: marker_layer = resultview.marker_layer if tofield.get_text() and not tofield.get_marker(): searcher = Searcher(marker_layer, resultview.liststore) text = tofield.get_text() searcher.search(text) resultview.show(_("Possible destination locations named: %(text)s" % {'text': text}), 2) # 2 -> show search results marker_layer.show() elif fromfield.get_text() and not fromfield.get_marker(): searcher = Searcher(marker_layer, resultview.liststore) text = fromfield.get_text() searcher.search(text) resultview.show(_("Possible departure locations named: %(text)s" % {'text': text}), 2) # 2 -> show search results marker_layer.show() else: print(_("Invalid search"))
def __EndCB(self,val,retval): if retval==True: try: devPath = val[0] uuidPath = val[1] fstype = val[2] #fstab editieren mounts = file('/etc/fstab').read().split('\n') newlines = [] for x in mounts: if x.startswith(devPath) or x.startswith("/dev/hdc1"):#/dev/hdc1 wegen 7025+ continue if uuidPath and x.startswith(uuidPath): continue if len(x)>1 and x[0]!='#': newlines.append(x) if fstype=="nfs": newlines.append("%s\t/usr\t%s\trw,nolock,timeo=14,intr\t0 0" %(devPath, fstype)) else: newlines.append("%s\t/usr\tauto\tdefaults\t0 0" %(uuidPath)) fp = file("/etc/fstab", 'w') fp.write("#automatically edited by FlashExpander\n") for x in newlines: fp.write(x + "\n") fp.close() print "[FlashExpander] write new /etc/fstab" self.session.openWithCallback(self.Exit, MessageBox, _("Do you want to reboot your STB_BOX?")) except: self.session.open(MessageBox, _("error adding fstab entry for: %s") % (devPath), MessageBox.TYPE_ERROR, timeout=5) return else: self.session.open(MessageBox, _("error copy flash memory"), MessageBox.TYPE_ERROR, timeout=10)
def __init__(self, filename=None): """Initialize the MenulibreDesktopEntry instance.""" self.filename = filename self.properties = OrderedDict() self.text = "" if filename: if os.path.isfile(filename): self.load_properties(filename) self.id = os.path.basename(filename) else: pass else: self.properties['Desktop Entry'] = OrderedDict() self.properties['Desktop Entry']['Version'] = '1.0' self.properties['Desktop Entry']['Type'] = 'Application' self.properties['Desktop Entry']['Name'] = _('New Menu Item') self.properties['Desktop Entry']['Comment'] = _( "A small descriptive blurb about this application.") self.properties['Desktop Entry'][ 'Icon'] = 'application-default-icon' self.properties['Desktop Entry']['Exec'] = '' self.properties['Desktop Entry']['Path'] = '' self.properties['Desktop Entry']['Terminal'] = 'false' self.properties['Desktop Entry']['StartupNotify'] = 'false' self.properties['Desktop Entry']['Categories'] = ''
def ok(self): self.IPTVInstalled = True url = None sel = self["IPTVList"].l.getCurrentSelection() if sel == None: print"Nothing to select !!" return for l in self.downloadlist: if len(sel) >= 3: if sel == l[3]: url = l[2] self.type = l[1] if self.type == "WEBCAM": self.type = "TV" break if url == None: self.session.open(MessageBox,_("Error, no url found"), MessageBox.TYPE_INFO) return file = self.Fetch_URL(url) if file.startswith("HTTP ERROR:"): self.session.open(MessageBox,_(file), MessageBox.TYPE_INFO) return self.Convert_m3u(sel, file) infotext = _('IPTV List Updater %s\n' % self.Version) infotext += _('(c) by Nobody28 & satinfo\n\n') infotext += _('IPTV Streams from HasBahCa & FreeTuxTV') infotext += _('\n\n\n') infotext += _('Update Bouquets and Services for:') infotext += _(' %s\n' % sel.upper() + '\n') infotext += _('Press OK or EXIT to go back !') self.session.open(MessageBox,_(infotext), MessageBox.TYPE_INFO)
def reload_global(self, settings, key, user_data): value = settings.get_string(key) if value == 'disabled': return try: self.guake.hotkeys.unbind(self.globalhotkeys[key]) except Exception as e: pass self.globalhotkeys[key] = value if key == "show-hide": log.debug("reload_global: %r", value) if not self.guake.hotkeys.bind(value, self.guake.show_hide): keyval, mask = Gtk.accelerator_parse(value) label = Gtk.accelerator_get_label(keyval, mask) filename = pixmapfile('guake-notification.png') notifier.showMessage( _('Guake Terminal'), _( 'A problem happened when binding <b>%s</b> key.\n' 'Please use Guake Preferences dialog to choose another ' 'key' ) % label, filename ) elif key == "show-focus": if not self.guake.hotkeys.bind(value, self.guake.show_focus): log.warn("can't bind show-focus key") return
def mk_notebook_context_menu(callback_object): """Create the context menu for the notebook """ callback_object.context_menu = Gtk.Menu() menu = callback_object.context_menu mi = Gtk.MenuItem(_("New Tab")) mi.connect("activate", callback_object.on_new_tab) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.MenuItem(_("Save Tabs")) mi.connect("activate", callback_object.on_save_tabs) menu.add(mi) mi = Gtk.MenuItem(_("Restore Tabs")) mi.connect("activate", callback_object.on_restore_tabs_with_dialog) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.ImageMenuItem("gtk-preferences") mi.set_use_stock(True) mi.connect("activate", callback_object.on_show_preferences) menu.add(mi) mi = Gtk.ImageMenuItem("gtk-about") mi.set_use_stock(True) mi.connect("activate", callback_object.on_show_about) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.MenuItem(_("Quit")) mi.connect("activate", callback_object.on_quit) menu.add(mi) menu.show_all() return menu
def __init__(self, session, comlist): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "cancel": self.Exit, "green": self.KeyGreen, #"red": self.KeyRed }, -1) self.setTitle(_("execute")) self["PixmapButton"] = MultiPixmap() self["LabelButton"] = Label(_("Start") + " ?") self.mountlist = [] list = [] for x in comlist: print x list.append((x[1], None, x[0])) if x[2] is not None: self.mountlist.append(x[2]) self["list"] = List(list) self.__Stimer = eTimer() self.__Stimer_conn = self.__Stimer.timeout.connect(self.__exeList) self.__state = -1
def on_import_clicked(self, widget): dialog = Gtk.FileChooserDialog(_("Open file"), self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) self.add_filters(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: filename = dialog.get_filename() track = GpxTrack(self.view, self.trackstore) try: track.import_file(filename) except: print(_("Import error: Could not find %(file)s" % {'file': filename})) else: track.show() track.go_to() self.sidebartogglebutton.set_active(True) elif response == Gtk.ResponseType.CANCEL: pass dialog.destroy()
def __init__(self, session, args = None): self.session = session path = "/usr/lib/enigma2/python/Plugins/Extensions/IPTV-List-Updater/skins/original/Changelog.xml" print path with open(path, "r") as f: self.skin = f.read() f.close() Screen.__init__(self, session) self["title"] = Label(_("Version 1.33")) self["text"] = ScrollLabel() self["actions"] = NumberActionMap(["WizardActions", "OkCancelActions", "ColorActions"], { "back": self.close, "red": self.close, "up": self["text"].pageUp, "down": self["text"].pageDown, }, -1) self["key_red"] = Label(_("Close")) change = self.Ausgabe() self["text"].setText(change)
def _make_menu_base(self): """ Make unchangeable menu base :return: """ self.menu = Gtk.Menu() #self.more_menu = Gtk.Menu() #self.more_item = self.__text_menu_item(_("More")) #self.more_item.set_submenu(self.more_menu) #self.menu.append(self.more_item) self.menu.append(Gtk.SeparatorMenuItem()) options_item = self.__text_menu_item(_("Options"), self.sig_handler.on_menu_options) self.menu.append(options_item) log_item = self.__text_menu_item(_("Log"), self.sig_handler.on_menu_log) self.menu.append(log_item) self.menu.append(Gtk.SeparatorMenuItem()) quit_item = self.__text_menu_item(_("Quit"), self.sig_handler.on_menu_quit) self.menu.append(quit_item) self.menu.show_all()
def on_print_icoming_document1_activate(self, event): sTo = [self.singleAddress.getEmail()] dicOrder = {} print "Start print incoming document 1" dicOrder['incomingNumber'] = self.rpc.callRP('Garden.getIncomingNumber',self.singleHibernation.ID, self.dicUser) print "Start print incoming document 2" dicOrder['orderNumber'] = self.singleHibernation.ID print "Start print incoming document 3" PDF = self.rpc.callRP('Report.server_hibernation_incoming_document', dicOrder, self.dicUser) fname = self.showPdf(PDF, self.dicUser,'INCOMING') print '1' print self.documentTools, self.singleDMS self.documentTools.importDocument(self.singleDMS,self.dicUser,fname) print '1.5' self.singleDMS.ModulNumber = self.MN['Hibernation'] print '2' self.singleDMS.sep_info_1 = self.singleHibernation.ID self.singleDMS.newRecord() print '3' self.singleDMS.newDate = self.getActualDateTime()['date'] print '4' self.singleDMS.newTitle = _('incomming') + ' ' + `dicOrder['incomingNumber'] ` print self.singleDMS.newDate print '5' self.singleDMS.newCategory = _('incomming') self.singleDMS.Rights = 'INCOMMING' print '6' newID = self.singleDMS.save(['document_image']) print '7' dicVars = {} dicVars['sm'] = self.getHibernationInfo() print '8' for key in dicOrder.keys(): dicVars['sm']['delivery_' + key] = dicOrder[key] print '9' print 'pickup=', self.dicUser['Email']['sendGet'], sTo[0] if self.dicUser['Email']['sendGet'] and sTo[0]: print '10' cmm = cuon.Misc.messages.messages() print '11' if cmm.QuestionMsg(_('Would you send it as email ?')): print '12' self.singleDMS.load(newID) cme = cuon.Misc.misc.sendAsEmail() print '13' cme.sendNormal('Incomming2', sTo, self.dicUser, self.singleDMS, dicVars) print '14'
def __checkMountPoint(self,mp): if mp == False: self.session.open(MessageBox, _("Mount failed (%s)") %fstype, MessageBox.TYPE_ERROR, timeout=5) return False if getFreeSize(mp)<180: self.session.open(MessageBox, _("Too little free space < 180MB or wrong Filesystem!"), MessageBox.TYPE_ERROR, timeout=5) return False return True
def _on_remove_button__clicked(self, widget): retval = yesno(_(u'Remove Resource'), _(u'Are you sure you want to remove the selected resource ?'), parent=self._parent) if retval == Gtk.ResponseType.YES: resource = self._get_current_selected() if resource: self._manager.remove_resource(resource)
def __init__(self): self.dicReportData = {} self.dicReportData['Title'] = _('Index Card') self.dicReportData['lPageNumber'] = _('Pagenumber:') self.dicReportData['fPageNumber'] = 1 self.dicReportData['Lastname'] = _('Lastname : ')
def myExecute(cmd, session, test=False): if test: from time import sleep sleep(5) result = 0 else: res = os_system(cmd) result = (res >> 8) print("[eParted]", result, cmd) if result != 0 and session is not None: session.open(MessageBox, _("Error command '%s'") % cmd, MessageBox.TYPE_ERROR, timeout=8) return result
def open(self, path=PortfolioPlaces.PORTFOLIO_HOME_DIR): # XXX so cheap ! path = path.replace("file://", "") # make sure it exists though ! if not os.path.exists(path): logger.warning(_("Could not open %s") % path) return # if it's a file then use its parent folder if not os.path.isdir(path): self._to_select = path path = os.path.dirname(path) # XXX no support for background workers yet if self._busy and not isinstance(self._worker, PortfolioLoadWorker): logger.warning(_("Could not open %s") % path) return if isinstance(self._worker, PortfolioLoadWorker): self._worker.stop() self._clean_workers() self._reset_to_path(path)
def __init__(self, config): self.config = config Gtk.Grid.__init__( self, column_spacing=6, margin_bottom=12, margin_left=12, margin_right=12, margin_top=12, row_spacing=6, ) section = self._add_section(_('Duration')) self.attach(section, 0, 0, 1, 1) # Pomodoro Duration label, setting = self._add_setting( _('Pomodoro:'), Gtk.SpinButton.new_with_range(1, 99, 1), 'pomodoro_duration') self.attach(label, 0, 1, 1, 1) self.attach_next_to(setting, label, Gtk.PositionType.RIGHT, 3, 1) # Short Break Duration label, setting = self._add_setting( _('Short break:'), Gtk.SpinButton.new_with_range(1, 99, 1), 'shortbreak_duration') self.attach(label, 0, 2, 1, 1) self.attach_next_to(setting, label, Gtk.PositionType.RIGHT, 3, 1) # Long Break Duration label, setting = self._add_setting( _('Long Break'), Gtk.SpinButton.new_with_range(1, 99, 1), 'longbreak_duration') self.attach(label, 0, 3, 1, 1) self.attach_next_to(setting, label, Gtk.PositionType.RIGHT, 3, 1)
def __init__(self, parent, command): # Translators: Not Found In PATH Dialog, primary text. Indicates # that the provided script was not found in any PATH directory. primary = _("Could not find \"%s\" in your PATH.") % command path = os.getenv("PATH", "").split(":") secondary = "<b>PATH:</b>\n%s" % "\n".join(path) Gtk.MessageDialog.__init__(self, transient_for=parent, modal=True, message_type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, text=primary) self.format_secondary_markup(secondary) self.connect("response", self.response_cb)
def date(title=_("Choose Date"), text=_("Choose a Date:"), default_value=None): """date - prompts to enter a date using a calendar via a dialog box. aguments: title - a string to be the title of the dialog text - a string to provide a prompt for the user within dialog default_value - a tuple in the form of integers for (year,month,day) where month is zero indexed (Jaunary is 0, December is 11) returns a tuple of (Gtk.DialogResponse, tuple) The returnd tuple is in the form of integers for (year,month,day) where month is zero indexed (Jaunary is 0, December is 11) Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise the user cancelled (Gtk.ResponseType.CANCEL) or dismissed the dialog (Gtk.ResponseType.DELETE_EVENT) """ dp = DatePrompt(title, text, default_value) response = dp.run() val = dp.get_value() dp.destroy() return (response, val)
def open_folder(self, notification, action, user_data=None): try: video_folder_for_open = self.settings.get_string( 'path-to-save-video-folder') Gio.AppInfo.launch_default_for_uri( "file:///" + video_folder_for_open.lstrip("/")) except Exception as error: dialog = Gtk.MessageDialog(transient_for=self, type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.OK, text=_("Unable to open folder")) dialog.format_secondary_text(str(error)) dialog.run() dialog.destroy()
def save_profile(self, profile_name, check_exists=False): if self.device is None: return if profile_name is None or profile_name == '': return profile_file = os.path.join(self.app.profile_path, profile_name + '.ini') if check_exists: if os.path.exists(profile_file): if not self.ui.confirmation_dialog( _("This profile already exists. Are you sure?")): raise Exception() self.model.save(profile_file)
def on_selector_moved(self, pos): """Show the object (type) that is located at the cursor position.""" count = 0 for symbol in self.objects: if symbol.pickpoint_pos == pos: last_found = symbol count += 1 if count > 1: msg = _("More than one item at position: {} !").format(pos) pub.sendMessage('STATUS_MESSAGE', msg=msg, type=WARNING) elif count == 1: msg = "Object: " + last_found.name pub.sendMessage('STATUS_MESSAGE', msg=msg) else: pub.sendMessage('STATUS_MESSAGE', msg="")
def __init__(self, app, *args, **kwargs): super().__init__(*args, title=_("Theme Switcher"), application=app) self._main_box.set_border_width(10) self.set_default_geometry(600, 200) self.settings = Gio.Settings.new(constants["BASE_KEY"]) self.set_wmclass("Theme Switcher", _("Theme Switcher")) #init header_bar self.header_bar = HeaderBar() self.set_titlebar(self.header_bar) self.header_bar.show() #init two containers for our widgets self.upper_grid = UpperGrid() self.middle_box = MiddleGrid() self.bottom_box = BottomBox() #add our containers to the main one self._main_box.add(self.upper_grid) self._main_box.add(self.middle_box) self._main_box.add(self.bottom_box)
def install_udev_files(self): if not self.check_permissions: return while True: affirmative = self.ui.confirmation_dialog( _("You don't have the " + "required permissions to change your wheel settings. You can " + "fix it yourself by copying the files in {} to the {} directory " + "and rebooting.").format(self.app.udev_path, self.app.target_dir) + "\n\n" + _("Do you want us to make this change for you?")) if affirmative: copy_cmd = '' for udev_file in self.app.udev_files: copy_cmd += 'cp -f ' + udev_file + ' ' + self.app.target_dir + ' && ' return_code = subprocess.call([ 'pkexec', '/bin/sh', '-c', copy_cmd + 'udevadm control --reload-rules && udevadm trigger', ]) if return_code == 0: self.ui.info_dialog( _("Permissions rules installed."), _("In some cases, a system restart might be needed.")) break answer = self.ui.confirmation_dialog( _("Error installing " + "permissions rules. Please, try again and make sure you " + "use the right password for the administrator user.")) if not answer: break else: break
def cancel_updates(self, *_args, **_kwargs): # pylint: disable=attribute-defined-outside-init if self.update_thread and self.update_thread.is_alive(): self.exit_triggered = True dialog = Gtk.MessageDialog( self.main_window, Gtk.DialogFlags.MODAL, Gtk.MessageType.OTHER, Gtk.ButtonsType.NONE, _("Cancelling remaining updates...")) dialog.show() while self.update_thread.is_alive(): while Gtk.events_pending(): Gtk.main_iteration() time.sleep(1) dialog.hide() else: self.exit_updater()
def create_file_chooser(self, current_folder): dialog = Gtk.FileChooserDialog( _("Please choose a file"), self.widget, Gtk.FileChooserAction.OPEN, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK, ), ) dialog.add_filter(self.create_filter("audio/mp3", "audio/mpeg")) dialog.add_filter(self.create_filter("audio/ogg", "audio/ogg")) dialog.set_current_folder(current_folder) return dialog
def setup_ui(self, launchers): """Initialize the headerbar, actions, and individual views""" self.hb = Gtk.HeaderBar() self.hb.props.show_close_button = True self.hb.props.title = self.title self.set_titlebar(self.hb) self.set_wmclass("sgt-launcher", _("SGT Puzzles Collection")) self.stack = Gtk.Stack.new() self.add(self.stack) self.setup_action_buttons() self.setup_launcher_view(launchers) self.setup_loading_view() self.setup_game_view()
def parse_options(): """Support for command line options""" parser = optparse.OptionParser(version="%%prog %s" % get_version()) parser.add_option( "-v", "--verbose", action="count", dest="verbose", help=_("Show debug messages (-vv debugs uberwriter_lib also)")) (options, args) = parser.parse_args() set_up_logging(options) # print args return options, args
def on_rename_profile_activate(widget): entry.disconnect_by_func(on_rename_profile_focus_out) source_profile_name = label.get_text() target_profile_name = widget.get_text() row.remove(widget) row.add(label) try: self.controller.rename_profile(source_profile_name, target_profile_name) label.set_text(target_profile_name) self.ui.profile_listbox.invalidate_sort() self.ui.update_profiles_combobox() except (KeyboardInterrupt, SystemExit): raise except Exception as e: self.ui.error_dialog(_('Error renaming profile'), str(e))
def __init__(self, vm, updates_available, **properties): super().__init__(**properties) self.vm = vm hbox = Gtk.HBox(orientation=Gtk.Orientation.HORIZONTAL) self.label_text = vm.name self.updates_available = updates_available if self.updates_available: self.label_text = _("{vm} (updates available)").format( vm=self.label_text) self.label = Gtk.Label() self.icon = get_domain_icon(self.vm) self.checkbox = Gtk.CheckButton() self.checkbox.set_active(self.updates_available) self.checkbox.set_margin_right(10) self.checkbox.connect("clicked", self.set_label_text) self.set_sensitive(self.updates_available) self.set_label_text() hbox.pack_start(self.checkbox, False, False, 0) hbox.pack_start(self.icon, False, False, 0) hbox.pack_start(self.label, False, False, 0) # check for VMs that may be restored from older Qubes versions # and not support updating; this is a heuristic and may not always work try: if vm.features.get('qrexec', False) and \ vm.features.get('gui', False) and \ not vm.features.get('os', False): warn_icon = Gtk.Image.new_from_pixbuf( Gtk.IconTheme.get_default().load_icon( 'dialog-warning', 12, 0)) warn_icon.set_tooltip_text( 'This qube may have been restored from an older version of ' 'Qubes and may not be able to update itself correctly. ' 'Please check the documentation if problems occur.') hbox.pack_start(warn_icon, False, False, 0) except exc.QubesDaemonCommunicationError: # we have no permission to access the vm's features, there's no # point in guessing original Qubes version pass self.add(hbox)
def __createCommandList(self): self.__comlist = [] #welche parts sollen gelöscht werden for x in range(len(self.__old_part_list)): if self.__old_part_list[x][LIST_TYPE] == LIST_TYPE_PAR: if bool(self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False: if len(self.__new_part_list) > x: if self.__old_part_list[x][ PA_SIZE] != self.__new_part_list[x][PA_SIZE]: #print self.__old_part_list[x], self.__new_part_list[x] self.__delPart2Comlist(self.__comlist, self.__old_part_list[x]) else: self.__delPart2Comlist(self.__comlist, self.__old_part_list[x]) #welche parts sollen erstellt werden for x in range(len(self.__new_part_list)): if self.__new_part_list[x][LIST_TYPE] == LIST_TYPE_PAR: if bool(self.__new_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False: if len(self.__old_part_list) > x and bool( self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False: if self.__new_part_list[x][ PA_SIZE] != self.__old_part_list[x][PA_SIZE]: #print self.__new_part_list[x], self.__old_part_list[x] self.__addPart2Comlist(self.__comlist, self.__new_part_list[x]) else: if self.__new_part_list[x][ PA_FS] != self.__old_part_list[x][PA_FS]: self.__addPart2Comlist(self.__comlist, self.__new_part_list[x], False) else: self.__addPart2Comlist(self.__comlist, self.__new_part_list[x]) #for x in self.__comlist: print "[eParted] com =",x if len(self.__comlist): self["PixmapBlue"].setPixmapNum(1) self["LabelBlue"].setText(_("execute")) else: self["PixmapBlue"].setPixmapNum(0) self["LabelBlue"].setText("")
def play_m3(m): skip = 0 type = m.group(1) if type == TEXT: text = m.group(2) x, y = m.group(3, 4) pos = Pos(x, y) orientation = 0 symbol = Text(pos, text, orientation) self.selected_objects = [] self.add_selected_object(symbol) self.on_paste_objects(pos) else: msg = _("skipped: {}").format(type) pub.sendMessage('STATUS_MESSAGE', msg=msg, type=WARNING) skip = 1 return skip
def select_folder(self, parentwindow): """ Select a Directory. """ a = _("Please choose a directory") dialog = Gtk.FileChooserDialog( '{}'.format(a, ), parentwindow, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) response = dialog.run() filename = dialog.get_filename() dialog.destroy() if response == Gtk.ResponseType.OK: return filename else: return None
def _startKeyValidation(self): try: (yield ThreadedTask(self._keyValidationTask)) if not self.validKey: dialog = Gtk.MessageDialog( self.view.workspaceConfigurationDialog, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, _("The specified key is invalid!")) dialog.run() dialog.destroy() except TaskError, e: self.log.error("Error while validating the API key: {0}".format( str(e)))
def create_button(self, icon_name, tooltip_text, on_clicked, shortcut_name, **props): image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.BUTTON) image.show() tooltip = "{} ({})".format(_(tooltip_text), self.shortcuts.label(shortcut_name)) button = Gtk.Button(tooltip_text=tooltip, **props) button.add(image) button.connect("clicked", on_clicked) self.shortcuts.connect(shortcut_name, on_clicked) self.widget.pack_start(button) return button
def ok(self): self.IPTVInstalled = True self.type = "TV" sel = self["IPTVList"].l.getCurrentSelection() if sel == None: print "Nothing to select !!" return for l in self.downloadlist: self.convert = True if len(sel) >= 4: if sel == l[3]: url = l[2] if len(l) >= 5: if l[4] == "B": self.convert = False self.type = l[1] if self.type == "WEBCAM": self.type = "TV" break file = self.Fetch_URL(url) if file.startswith("HTTP ERROR:") or file.startswith( "SOCKET TIMEOUT ERROR:") or file.startswith( "HTTP download ERROR:") or file.startswith( "HTTP URL ERROR:"): self.session.open(MessageBox, _(file), MessageBox.TYPE_INFO) return self.Convert_m3u(sel, file) infotext = _('IPTV List Updater %s\n' % self.Version) infotext += _('(c) by Nobody28 & satinfo\n\n') infotext += _('IPTV Streams from HasBahCa & FreeTuxTV') infotext += _('\n\n\n') infotext += _('Update Bouquets and Services for:') infotext += _(' %s\n' % sel.upper() + '\n') infotext += _('Press OK or EXIT to go back !') self.session.open(MessageBox, _(infotext), MessageBox.TYPE_INFO)
def unordered_list_item(self): helptext = _("List item") text_length = len(helptext) move_back = 0 if self.TextBuffer.get_has_selection(): (start, end) = self.TextBuffer.get_selection_bounds() if start.starts_line(): text = self.TextBuffer.get_text(start, end, False) if text.startswith(("- ", "* ", "+ ")): delete_end = start.forward_chars(2) self.TextBuffer.delete(start, delete_end) else: self.TextBuffer.insert(start, "- ") else: move_back = 0 cursor_mark = self.TextBuffer.get_insert() cursor_iter = self.TextBuffer.get_iter_at_mark(cursor_mark) start_ext = cursor_iter.copy() start_ext.backward_lines(3) text = self.TextBuffer.get_text(cursor_iter, start_ext, False).decode("utf-8") lines = text.splitlines() for line in reversed(lines): if len(line) and line.startswith(("- ", "* ", "+ ")): if cursor_iter.starts_line(): self.TextBuffer.insert_at_cursor(line[:2] + helptext) else: self.TextBuffer.insert_at_cursor("\n" + line[:2] + helptext) break else: if len(lines[-1]) == 0 and len(lines[-2]) == 0: self.TextBuffer.insert_at_cursor("- " + helptext) elif len(lines[-1]) == 0: if cursor_iter.starts_line(): self.TextBuffer.insert_at_cursor("- " + helptext) else: self.TextBuffer.insert_at_cursor("\n- " + helptext) else: self.TextBuffer.insert_at_cursor("\n\n- " + helptext) break self.select_edit(move_back, text_length)
def __init__(self, title=_("Choose an option"), text="", yes="", no=""): """creaets a YesNoPrompt. aguments: title - a string to be the title of the dialog text - a string, typically a question, prompting the user to choose Yes or No yes - a string that is a verb representing the Yes action no - a string that is a verb representing the No action """ Gtk.Dialog.__init__(self, title, None, Gtk.DialogFlags.MODAL) if no == "": no_button = Gtk.Button(stock=Gtk.STOCK_NO) else: no_button = Gtk.Button(label=no, use_underline=True) self.add_action_widget(no_button, Gtk.ResponseType.NO) no_button.show() if yes == "": yes_button = Gtk.Button(stock=Gtk.STOCK_YES) else: yes_button = Gtk.Button(label=yes, use_underline=True) self.add_action_widget(yes_button, Gtk.ResponseType.YES) yes_button.show() yes_button.set_can_default(True) #self.set_has_separator(False) content_area = self.get_content_area() content_area.set_border_width(5) self.set_default_response(Gtk.ResponseType.YES) self.content_box = Gtk.HBox(False, 10) img = Gtk.Image() img.set_from_stock(Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG) self.content_box.pack_start(img, False, False, 5) label = Gtk.Label(text) label.set_line_wrap(True) self.content_box.pack_start(label, False, False, 5) content_area.pack_start(self.content_box, False, False, 5) self.content_box.show() label.show() img.show()
def __init__(self, parent): Gtk.AboutDialog.__init__(self) authors = ["Sean Davis"] documenters = ["Sean Davis"] # Translators: About Dialog, window title. self.set_title(_("About MenuLibre")) self.set_program_name("MenuLibre") self.set_logo_icon_name("menulibre") self.set_copyright("Copyright © 2012-2020 Sean Davis") self.set_authors(authors) self.set_documenters(documenters) self.set_website("https://github.com/bluesabre/menulibre") self.set_version(menulibre_lib.get_version()) # Connect the signal to destroy the AboutDialog when Close is clicked. self.connect("response", self.about_close_cb) self.set_transient_for(parent)
def info(title=_("Information"), text=""): """info - displays information to the user, includes an appropriate icon and an OK button aguments: title - a string to be the title of the dialog text - a string providing the information returns a Gtk.DialogResponse Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) """ i = Alert(title, text, Gtk.STOCK_DIALOG_INFO) response = i.run() i.destroy() return response
def delete(self, *args): if self.bbody.get_char_count(): # ask for only non-empty notes winConfirm = Gtk.MessageDialog( self.winMain, None, Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE, _("Are you sure you want to delete this note?")) winConfirm.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_DELETE, Gtk.ResponseType.ACCEPT) confirm = winConfirm.run() winConfirm.destroy() else: confirm = Gtk.ResponseType.ACCEPT if confirm == Gtk.ResponseType.ACCEPT: self.note.delete() self.winMain.destroy() return False else: return True
def error(title=_("Error"), text=""): """error - displays an error to the user, includes an appropriate icon and an OK button aguments: title - a string to be the title of the dialog text - a string describing the error returns a Gtk.DialogResponse Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) """ e = Alert(title, text, Gtk.STOCK_DIALOG_ERROR) response = e.run() e.destroy() return response
def warning(title=_("Warning"), text=""): """warning - displays a warning to the user, includes an appropriate icon and an OK button aguments: title - a string to be the title of the dialog text - a string describing the warning returns a Gtk.DialogResponse Gtk.ResponseType.OK means the user clicked the "OK" button, otherwise the user dismissed the dialogv(Gtk.ResponseType.DELETE_EVENT) """ w = Alert(title, text, Gtk.STOCK_DIALOG_WARNING) response = w.run() w.destroy() return response