def OnCheckbox(self, event): checkbox = event.GetEventObject() checkbox.Enable(False) wx.CallLater(1000, checkbox.Enable, True) wx.CallLater(100, self.__toggleFF, event.GetEventObject().GetValue())
def delayScriptTask(func, *args, **kwargs): global GB_scriptTaskTimer from ..settings import _addonConfigManager delay = _addonConfigManager.getMaximumDelayBetweenSameScript() GB_scriptTaskTimer = wx.CallLater(delay, func, *args, **kwargs)
def test_embed_ownFrame(): gc.collect() idle.idleLoop.reset() app = wx.App() frame = [wx.Frame(None)] sizer = wx.BoxSizer(wx.HORIZONTAL) frame[0].SetSizer(sizer) panel = [None] ncalls = [0] def finish(): frame[0].Close() app.ExitMainLoop() def reset(): print('Resetting', ncalls) sizer.Remove(0) panel[0].destroy() panel[0].Destroy() panel[0] = None def open_fsleyes(): print('Embedded call', ncalls[0]) overlayList, displayCtx, fframe = fslmain.embed(mkFrame=False, menu=False, save=False) assert fframe is None img = fslimage.Image(op.join(datadir, '3d')) overlayList.append(img) cdctx = displaycontext.DisplayContext(overlayList, displayCtx) panel[0] = orthopanel.OrthoPanel(frame[0], overlayList, cdctx, None) sizer.Add(panel[0], flag=wx.EXPAND, proportion=1) frame[0].Layout() frame[0].Refresh() ncalls[0] += 1 wx.CallLater(1500, reset) if ncalls[0] < 4: wx.CallLater(2500, open_fsleyes) else: print('Done - closing') wx.CallLater(2500, finish) wx.CallLater(1000, open_fsleyes) frame[0].Show() app.MainLoop() assert ncalls[0] == 4
def __do_layout(self): grid_sizer_base = wx.FlexGridSizer(rows=5, cols=1, vgap=10, hgap=10) grid_sizer_base.Add(self.ctrl_bandeau, 0, wx.EXPAND, 0) grid_sizer_contenu = wx.FlexGridSizer(rows=1, cols=2, vgap=10, hgap=10) grid_sizer_gauche = wx.FlexGridSizer(rows=4, cols=1, vgap=5, hgap=5) # Modèle box_modele = wx.StaticBoxSizer(self.box_modele_staticbox, wx.VERTICAL) grid_sizer_modele1 = wx.FlexGridSizer(rows=2, cols=2, vgap=5, hgap=5) grid_sizer_modele1.Add(self.label_categorie, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_modele1.Add(self.ctrl_categorie, 0, wx.EXPAND, 0) grid_sizer_modele1.Add(self.label_modele, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_modele2 = wx.FlexGridSizer(rows=1, cols=2, vgap=5, hgap=5) grid_sizer_modele2.Add(self.ctrl_modele, 0, wx.EXPAND, 0) grid_sizer_modele2.Add(self.bouton_modele, 0, 0, 0) grid_sizer_modele2.AddGrowableCol(0) grid_sizer_modele1.Add(grid_sizer_modele2, 1, wx.EXPAND, 0) grid_sizer_modele1.AddGrowableCol(1) box_modele.Add(grid_sizer_modele1, 1, wx.ALL | wx.EXPAND, 5) grid_sizer_gauche.Add(box_modele, 1, wx.EXPAND, 0) # Gabarit box_gabarit = wx.StaticBoxSizer(self.box_gabarit_staticbox, wx.VERTICAL) grid_sizer_gabarit = wx.FlexGridSizer(rows=4, cols=4, vgap=2, hgap=5) grid_sizer_gabarit.Add(self.label_largeur_page, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_largeur_page, 0, wx.RIGHT, 10) grid_sizer_gabarit.Add(self.label_marge_haut, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_marge_haut, 0, 0, 0) grid_sizer_gabarit.Add(self.label_hauteur_page, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_hauteur_page, 0, 0, 0) grid_sizer_gabarit.Add(self.label_marge_bas, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_marge_bas, 0, 0, 0) grid_sizer_gabarit.Add(self.label_espace_vertic, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_espace_vertic, 0, 0, 0) grid_sizer_gabarit.Add(self.label_marge_gauche, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_marge_gauche, 0, 0, 0) grid_sizer_gabarit.Add(self.label_espace_horiz, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_espace_horiz, 0, 0, 0) grid_sizer_gabarit.Add(self.label_marge_droite, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_gabarit.Add(self.ctrl_marge_droite, 0, 0, 0) box_gabarit.Add(grid_sizer_gabarit, 1, wx.ALL | wx.EXPAND, 5) grid_sizer_gauche.Add(box_gabarit, 1, wx.EXPAND, 0) # Options box_options = wx.StaticBoxSizer(self.box_options_staticbox, wx.VERTICAL) grid_sizer_options = wx.FlexGridSizer(rows=1, cols=6, vgap=5, hgap=5) grid_sizer_options.Add(self.label_nbre_copies, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_options.Add(self.ctrl_nbre_copies, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_options.Add((10, 5), 0, 0, 0) grid_sizer_options.Add(self.check_contour, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_options.Add(self.check_reperes, 0, wx.ALIGN_CENTER_VERTICAL, 0) box_options.Add(grid_sizer_options, 1, wx.ALL | wx.EXPAND, 5) grid_sizer_gauche.Add(box_options, 1, wx.EXPAND, 0) # Aperçu box_apercu = wx.StaticBoxSizer(self.box_apercu_staticbox, wx.VERTICAL) box_apercu.Add(self.ctrl_apercu, 1, wx.ALL | wx.EXPAND, 5) grid_sizer_gauche.Add(box_apercu, 1, wx.EXPAND, 0) grid_sizer_gauche.AddGrowableRow(3) grid_sizer_gauche.AddGrowableCol(0) grid_sizer_contenu.Add(grid_sizer_gauche, 1, wx.EXPAND, 0) # Données box_donnees = wx.StaticBoxSizer(self.box_donnees_staticbox, wx.VERTICAL) grid_sizer_donnees = wx.FlexGridSizer(rows=2, cols=1, vgap=5, hgap=5) grid_sizer_donnees.Add(self.ctrl_donnees, 1, wx.EXPAND, 0) grid_sizer_donnees.AddGrowableRow(0) grid_sizer_donnees.AddGrowableCol(0) box_donnees.Add(grid_sizer_donnees, 1, wx.ALL | wx.EXPAND, 5) grid_sizer_contenu.Add(box_donnees, 1, wx.EXPAND, 0) grid_sizer_contenu.AddGrowableRow(0) grid_sizer_contenu.AddGrowableCol(1) grid_sizer_base.Add(grid_sizer_contenu, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10) # Check Mémoriser grid_sizer_base.Add(self.ctrl_memoriser, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10) # Boutons grid_sizer_boutons = wx.FlexGridSizer(rows=1, cols=4, vgap=10, hgap=10) grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0) grid_sizer_boutons.Add((20, 20), 0, wx.EXPAND, 0) grid_sizer_boutons.Add(self.bouton_ok, 0, 0, 0) grid_sizer_boutons.Add(self.bouton_annuler, 0, 0, 0) grid_sizer_boutons.AddGrowableCol(1) grid_sizer_base.Add(grid_sizer_boutons, 1, wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10) grid_sizer_base.AddGrowableRow(1) grid_sizer_base.AddGrowableCol(0) self.SetSizer(grid_sizer_base) grid_sizer_base.Fit(self) self.Layout() self.CenterOnScreen() wx.CallLater(0, self.Layout) # Contre pb d'affichage du wx.Choice
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX) self.parent = parent intro = _( u"Sélectionnez un modèle de graphique dans la liste proposée puis ajustez les paramètres si besoin." ) titre = _(u"Graphiques") self.SetTitle(titre) self.ctrl_bandeau = CTRL_Bandeau.Bandeau( self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Diagramme.png") # Modèle self.box_modele_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Modèle")) self.ctrl_modele = CTRL_Modele(self) self.ctrl_modele.SetMinSize((400, -1)) # Paramètres self.box_parametres_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Paramètres")) self.label_exercice = wx.StaticText(self, wx.ID_ANY, _(u"Exercice :")) self.ctrl_exercice = CTRL_Exercice(self) self.label_analytique = wx.StaticText(self, wx.ID_ANY, _(u"Analytique :")) self.ctrl_analytique = CTRL_Analytique(self) # Graphique self.box_graphique_staticbox = wx.StaticBox(self, wx.ID_ANY, "Graphique") self.ctrl_graphique = CTRL_Graphique(self) self.bouton_zoom = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Apercu.png"), wx.BITMAP_TYPE_ANY)) self.bouton_options = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Mecanisme.png"), wx.BITMAP_TYPE_ANY)) # Boutons self.bouton_aide = CTRL_Bouton_image.CTRL( self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_ok = CTRL_Bouton_image.CTRL( self, texte=_(u"Fermer"), cheminImage="Images/32x32/Fermer.png") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_COMBOBOX, self.OnChoixModele, self.ctrl_modele) self.Bind(wx.EVT_CHOICE, self.OnChoixExercice, self.ctrl_exercice) self.Bind(wx.EVT_CHOICE, self.OnChoixAnalytique, self.ctrl_analytique) self.Bind(wx.EVT_BUTTON, self.ctrl_graphique.OnBoutonZoom, self.bouton_zoom) self.Bind(wx.EVT_BUTTON, self.ctrl_graphique.OnBoutonOptions, self.bouton_options) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_ok) # Init contrôles wx.CallLater(1, self.MAJgraphique)
def __init__(self, frame, title, params, order, helpUrl=None, suppressTitles=True, size=wx.DefaultSize, style=_style, editing=False, depends=[], timeout=None): # translate title localizedTitle = title.replace(' Properties', _translate(' Properties')) wx.Dialog.__init__(self, None, -1, localizedTitle, size=size, style=style) self.frame = frame self.app = frame.app self.helpUrl = helpUrl self.params = params # dict self.order = order self.title = title self.timeout = timeout self.warningsDict = {} # to store warnings for all fields # keep localized title to update dialog's properties later. self.localizedTitle = localizedTitle self.codeBoxes = {} self.tabs = OrderedDict() if not editing and 'name' in self.params: # then we're adding a new component so ensure a valid name: makeValid = self.frame.exp.namespace.makeValid self.params['name'].val = makeValid(params['name'].val) agwStyle = flatnotebook.FNB_NO_X_BUTTON if hasattr(flatnotebook, "FNB_NAV_BUTTONS_WHEN_NEEDED"): # not available in wxPython 2.8 agwStyle |= flatnotebook.FNB_NAV_BUTTONS_WHEN_NEEDED if hasattr(flatnotebook, "FNB_NO_TAB_FOCUS"): # not available in wxPython 2.8.10 agwStyle |= flatnotebook.FNB_NO_TAB_FOCUS self.codeNotebook = flatnotebook.FlatNotebook(self, wx.ID_ANY, style=agwStyle) openToPage = None tabN = -1 for paramN, paramName in enumerate(self.order): param = self.params.get(paramName) if paramName == 'name': self.nameLabel = wx.StaticText(self, wx.ID_ANY, _translate(param.label)) _style = wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB self.componentName = wx.TextCtrl(self, wx.ID_ANY, str(param.val), style=_style) self.componentName.SetToolTipString( _translate(param.hint)) self.componentName.SetValidator(validators.NameValidator()) self.nameOKlabel = wx.StaticText(self, -1, '', style=wx.ALIGN_RIGHT) self.nameOKlabel.SetForegroundColour(wx.RED) elif paramName == 'Code Type': _codeTypes = self.params['Code Type'].allowedVals self.codeTypeMenu = wx.Choice(self, choices=_codeTypes) self.codeTypeMenu.SetSelection( _codeTypes.index(self.params['Code Type'])) self.codeTypeMenu.Bind(wx.EVT_CHOICE, self.OnCodeChoice) self.codeTypeName = wx.StaticText(self, wx.ID_ANY, _translate(param.label)) else: tabName = paramName.replace("JS ", "") if tabName in self.tabs: _panel = self.tabs[tabName] else: _panel = wx.Panel(self.codeNotebook, wx.ID_ANY) self.tabs[tabName] = _panel tabN += 1 self.codeBoxes[paramName] = CodeBox(_panel, wx.ID_ANY, pos=wx.DefaultPosition, style=0, prefs=self.app.prefs) self.codeBoxes[paramName].AddText(param.val) if len(param.val.strip()) and openToPage is None: # index of first non-blank page openToPage = tabN if self.helpUrl is not None: self.helpButton = wx.Button(self, wx.ID_HELP, _translate(" Help ")) tip = _translate("Go to online help about this component") self.helpButton.SetToolTip(wx.ToolTip(tip)) self.okButton = wx.Button(self, wx.ID_OK, _translate(" OK ")) self.okButton.SetDefault() self.cancelButton = wx.Button(self, wx.ID_CANCEL, _translate(" Cancel ")) self.__set_properties() self.__do_layout() if openToPage is None: openToPage = 0 self.codeNotebook.SetSelection(openToPage) self.Update() self.Bind(wx.EVT_BUTTON, self.helpButtonHandler, self.helpButton) if self.timeout: timeout = wx.CallLater(self.timeout, self.onEnter) timeout.Start() # do show and process return ret = self.ShowModal() if ret == wx.ID_OK: self.checkName() self.OK = True self.params = self.getParams() # get new vals from dlg self.Validate() # TODO: check syntax of code from each code section tab?? else: self.OK = False
def __init__( self, parent, giface=None, id=wx.ID_ANY, title=_("Data catalog"), name="catalog", **kwargs, ): """Panel constructor""" self.showNotification = Signal("DataCatalog.showNotification") self.parent = parent self.baseTitle = title self.giface = giface self._startLoadingTime = 0 wx.Panel.__init__(self, parent=parent, id=id, **kwargs) self.SetName("DataCatalog") Debug.msg(1, "DataCatalog.__init__()") # toolbar self.toolbar = DataCatalogToolbar(parent=self) # search self.search = DataCatalogSearch(parent=self, filter_function=self.Filter) # tree with layers self.tree = DataCatalogTree(self, giface=giface) self.tree.showNotification.connect(self.showNotification) # infobar for data catalog delay = 2000 self.infoBar = InfoBar(self) self.giface.currentMapsetChanged.connect(self.dismissInfobar) # infobar manager for data catalog self.infoManager = DataCatalogInfoManager( infobar=self.infoBar, giface=self.giface ) self.tree.showImportDataInfo.connect(self.showImportDataInfo) self.tree.loadingDone.connect(self._loadingDone) # some layout self._layout() # show infobar for first-time user if applicable if is_first_time_user(): # show data structure infobar for first-time user wx.CallLater(delay, self.showDataStructureInfo) # show infobar if last used mapset is not usable if is_fallback_session(): # get reason why last used mapset is not usable last_mapset_path = gisenv()["LAST_MAPSET_PATH"] self.reason_id = get_reason_id_mapset_not_usable(last_mapset_path) if self.reason_id in ("non-existent", "invalid", "different-owner"): # show non-standard situation info wx.CallLater(delay, self.showFallbackSessionInfo) elif self.reason_id == "locked": # show info allowing to switch to locked mapset wx.CallLater(delay, self.showLockedMapsetInfo)
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX) self.parent = parent # Bandeau titre = _(u"Solder les impayés") intro = _( u"Cette fonctionnalité vous permet de laisser Noethys créer des règlements pour les prestations impayées d'une période donnée. Utile pour remettre les comptes à zéro par exemple." ) self.SetTitle(titre) self.ctrl_bandeau = CTRL_Bandeau.Bandeau( self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Impayes.png") # Règlement self.box_reglement_staticbox = wx.StaticBox( self, -1, _(u"Paramètres des règlements")) self.label_compte = wx.StaticText(self, -1, _(u"Compte :")) self.ctrl_compte = CTRL_Compte(self) self.bouton_compte = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Mecanisme.png"), wx.BITMAP_TYPE_ANY)) self.label_mode = wx.StaticText(self, -1, _(u"Mode :")) self.ctrl_mode = CTRL_Mode(self) self.bouton_mode = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Mecanisme.png"), wx.BITMAP_TYPE_ANY)) self.label_emetteur = wx.StaticText(self, -1, _(u"Emetteur :")) self.ctrl_emetteur = CTRL_Emetteur(self) self.bouton_emetteur = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Mecanisme.png"), wx.BITMAP_TYPE_ANY)) # Prestations self.box_prestations_staticbox = wx.StaticBox( self, -1, _(u"Sélection des prestations")) self.label_date_debut = wx.StaticText(self, -1, u"Du") self.ctrl_date_debut = CTRL_Saisie_date.Date2(self) self.label_date_fin = wx.StaticText(self, -1, "au") self.ctrl_date_fin = CTRL_Saisie_date.Date2(self) self.bouton_actualiser = wx.Button(self, -1, _(u"Actualiser la liste")) self.listviewAvecFooter = OL_Solder_impayes.ListviewAvecFooter( self, kwargs={}) self.ctrl_prestations = self.listviewAvecFooter.GetListview() self.ctrl_recherche = OL_Solder_impayes.CTRL_Outils( self, listview=self.ctrl_prestations, afficherCocher=True) # Boutons self.bouton_aide = CTRL_Bouton_image.CTRL( self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_ok = CTRL_Bouton_image.CTRL( self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png") self.bouton_annuler = CTRL_Bouton_image.CTRL( self, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_CHOICE, self.OnChoixMode, self.ctrl_mode) self.Bind(wx.EVT_BUTTON, self.OnBoutonCompte, self.bouton_compte) self.Bind(wx.EVT_BUTTON, self.OnBoutonMode, self.bouton_mode) self.Bind(wx.EVT_BUTTON, self.OnBoutonEmetteur, self.bouton_emetteur) self.Bind(wx.EVT_BUTTON, self.OnBoutonActualiser, self.bouton_actualiser) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok) self.Bind(wx.EVT_BUTTON, self.OnBoutonAnnuler, self.bouton_annuler) self.ctrl_prestations.MAJ() wx.CallLater(0, self.Layout)
#lv.data_selection = "datum2" # assign some event handlers: #lv.onitemselected = "" w.show() def update(p): if p == 1: gv.items[0][0] = "hola!" # change a cell programatically gv.items.insert(0, [10, 11, 12.]) # insert a row at first pos gv.items[2] = [99, 98, 97, 96.543] # replace a complete row del gv.items[-1] # delete the last row if p == 2: gv.items[0][3] = 1 / 2.0 print "updated!" wx.CallLater(2000, update, 1) wx.CallLater(3000, update, 2) #import wx.lib.inspection #wx.lib.inspection.InspectionTool().Show() # basic tests ##assert lv.get_count() == 4 ##lv.items(1).selected = True # check that internal selection match: ##assert lv.get_selected_items() == [{'col2': '5', 'col3': 6, 'col1': '4'}] ##if '--virtual' in sys.argv: ## lv.virtual = True ## #lv.ongetitemdata = lambda item, col: "row %d, col %d" % (item, col) ## lv.item_count = 10000000
def MAJpage(self, codePage=""): page = self.dictPages[codePage]["ctrl"] wx.CallLater(1, page.MAJ)
def emit(self): self.queuedCnt += 1 if self.disabledCnt == 0: if self.timer: self.timer.Stop() self.timer = wx.CallLater(self.delay, self.notifyListeners)
def MAJpageActive(self): """ MAJ la page active du notebook """ indexPage = self.GetSelection() page = self.GetPage(indexPage) wx.CallLater(1, page.MAJ)
def EnfonceBouton(self, actionActive=True): self.OnLeftDown(actionActive) wx.CallLater(200, self.ReleveBouton)
def __init__(self, parent, filename=None, id=wx.ID_ANY, title="PYME Visualise", pos=wx.DefaultPosition, size=(900, 750), style=wx.DEFAULT_FRAME_STYLE, use_shaders=True, cmd_args=None, pipeline_vars={}): AUIFrame.__init__(self, parent, id, title, pos, size, style) self.cmd_args = cmd_args self._flags = 0 self.pipeline = pipeline.Pipeline(visFr=self) self.pipeline.dataSources.update(pipeline_vars) visCore.VisGUICore.__init__(self, use_shaders=use_shaders) #self.Quads = None #self.SetMenuBar(self.CreateMenuBar()) self.CreateMenuBar(use_shaders=use_shaders) self.statusbar = self.CreateStatusBar(1, wx.STB_SIZEGRIP) self.statusbar.SetStatusText("", 0) #self._leftWindow1 = wx.Panel(self, -1, size = wx.Size(220, 1000)) #self._pnl = 0 #initialize the common parts ############################### #NB: this has to come after the shell has been generated, but before the fold panel ################################ self.MainWindow = self #so we can access from shell self.sh = wx.py.shell.Shell( id=-1, parent=self, size=wx.Size(-1, -1), style=0, locals=self.__dict__, startupScript=config.get('VisGUI-console-startup-file', None), introText= 'PYME console - note that help, license etc below is for Python, not PySMI\n\n' ) #self._mgr.AddPane(self.sh, aui.AuiPaneInfo(). # Name("Shell").Caption("Console").Centre().CloseButton(False).CaptionVisible(False)) self.AddPage(self.sh, caption='Shell') self.elv = None self.colp = None self.mdp = None self.rav = None self.generatedImages = [] self.sh.Execute('from pylab import *') self.sh.Execute('from PYME.DSView.dsviewer import View3D') import os if os.getenv( 'PYMEGRAPHICSFIX' ): # fix issue with graphics freezing on some machines (apparently matplotlib related) self.sh.Execute('plot()') self.sh.Execute('close()') #self.workspace = workspaceTree.WorkWrap(self.__dict__) ##### Make certain things visible in the workspace tree #components of the pipeline #col = self.workspace.newColour() #self.workspace.addKey('pipeline', col) #Generated stuff #col = self.workspace.newColour() #self.workspace.addKey('GeneratedMeasures', col) #self.workspace.addKey('generatedImages', col) #self.workspace.addKey('objects', col) #main window, so we can get everything else if needed #col = self.workspace.newColour() #self.workspace.addKey('MainWindow', col) ###### #self.workspaceView = workspaceTree.WorkspaceTree(self, workspace=self.workspace, shell=self.sh) #self.AddPage(page=wx.StaticText(self, -1, 'foo'), select=False, caption='Workspace') # self.glCanvas = gl_render.LMGLCanvas(self) # self.AddPage(page=self.glCanvas, select=True, caption='View') # self.glCanvas.cmap = pylab.cm.gist_rainbow #pylab.cm.hot #self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_MOVE, self.OnMove) self.Bind(wx.EVT_CLOSE, self.OnQuit) #self.Bind(wx.EVT_IDLE, self.OnIdle) #self.refv = False statusLog.SetStatusDispFcn(self.SetStatus) self.paneHooks.append(self.GenPanels) self.CreateFoldPanel() #from .layer_panel import CreateLayerPane, CreateLayerPanel #CreateLayerPane(sidePanel, self) #CreateLayerPanel(self) self._recipe_manager = recipeGui.PipelineRecipeManager(self.pipeline) self._recipe_editor = recipeGui.RecipeView(self, self._recipe_manager) self.AddPage(page=self._recipe_editor, select=False, caption='Pipeline Recipe') self.AddMenuItem('Recipe', 'Reconstruct from open image', self.reconstruct_pipeline_from_open_image) self.AddMenuItem('Recipe', 'Reconstruct from image file', self.reconstruct_pipeline_from_image_file) if not filename is None: def _recipe_callback(): recipe = getattr(self.cmd_args, 'recipe', None) print('Using recipe: %s' % recipe) if recipe: from PYME.recipes import modules self.pipeline.recipe.update_from_yaml(recipe) #self.recipeView.SetRecipe(self.pipeline.recipe) self.update_datasource_panel() wx.CallLater(50, self.OpenFile, filename, recipe_callback=_recipe_callback) #self.refv = False wx.CallAfter(self.RefreshView) nb = self._mgr.GetNotebooks()[0] nb.SetSelection(0)
def _blink_later(self): self.delay.Stop() self.delay = wx.CallLater(self.DELAY, self._blink)
def OnLeftClick ( self, event ) : if self.table != self : if self.table.GetTypeName ( event.Row, event.Col ) == \ gridlib.GRID_VALUE_BOOL : wx.CallLater ( 100, self.toggleCheckBox ) event.Skip()
def _stop_later(self): # Always stop blinking when handling an alarm off event, even in the # remote case that no alarm was found in self.active_alarms above self.sdelay.Stop() self.sdelay = wx.CallLater(self.SDELAY, self._stop)
def __init__(self, params, installdir, autoload_discovery=True, use_torrent_search=True, use_channel_search=True): assert not isInIOThread( ), "isInIOThread() seems to not be working correctly" self._logger = logging.getLogger(self.__class__.__name__) self.params = params self.installdir = installdir self.state_dir = None self.error = None self.last_update = 0 self.ready = False self.done = False self.frame = None self.upgrader = None self.said_start_playback = False self.decodeprogress = 0 self.old_reputation = 0 # DISPERSY will be set when available self.dispersy = None # BARTER_COMMUNITY will be set when both Dispersy and the EffortCommunity are available self.barter_community = None self.tunnel_community = None self.torrentfeed = None self.webUI = None self.utility = None # Stage 1 start session = self.InitStage1(installdir, autoload_discovery=autoload_discovery, use_torrent_search=use_torrent_search, use_channel_search=use_channel_search) self.splash = None try: bm = self.gui_image_manager.getImage(u'splash.png') self.splash = GaugeSplash(bm, "Loading...", 13) self.splash.Show() self._logger.info('Client Starting Up.') self._logger.info("Tribler is using %s as working directory", self.installdir) # Stage 2: show the splash window and start the session self.splash.tick('Starting API') s = self.startAPI(session, self.splash.tick) self.utility = Utility(self.installdir, s.get_state_dir()) if self.utility.read_config(u'saveas', u'downloadconfig'): DefaultDownloadStartupConfig.getInstance().set_dest_dir( self.utility.read_config(u'saveas', u'downloadconfig')) self.utility.set_app(self) self.utility.set_session(s) self.guiUtility = GUIUtility.getInstance(self.utility, self.params, self) GUIDBProducer.getInstance() self._logger.info('Tribler Version: %s Build: %s', version_id, commit_id) version_info = self.utility.read_config('version_info') if version_info.get('version_id', None) != version_id: # First run of a different version version_info['first_run'] = int(time()) version_info['version_id'] = version_id self.utility.write_config('version_info', version_info) self.splash.tick( 'Starting session and upgrading database (it may take a while)' ) s.start() self.dispersy = s.lm.dispersy self.splash.tick('Loading userdownloadchoice') from Tribler.Main.vwxGUI.UserDownloadChoice import UserDownloadChoice UserDownloadChoice.get_singleton().set_utility(self.utility) self.splash.tick('Initializing Family Filter') cat = Category.getInstance(session) state = self.utility.read_config('family_filter') if state in (1, 0): cat.set_family_filter(state == 1) else: self.utility.write_config('family_filter', 1) self.utility.flush_config() cat.set_family_filter(True) # Create global speed limits self.splash.tick('Setting up speed limits') # Counter to suppress some event from occurring self.ratestatecallbackcount = 0 maxup = self.utility.read_config('maxuploadrate') maxdown = self.utility.read_config('maxdownloadrate') # set speed limits using LibtorrentMgr s.set_max_upload_speed(maxup) s.set_max_download_speed(maxdown) # Only allow updates to come in after we defined ratelimiter self.prevActiveDownloads = [] s.set_download_states_callback(self.sesscb_states_callback) # Schedule task for checkpointing Session, to avoid hash checks after # crashes. startWorker(consumer=None, workerFn=self.guiservthread_checkpoint_timer, delay=SESSION_CHECKPOINT_INTERVAL) if not ALLOW_MULTIPLE: # Put it here so an error is shown in the startup-error popup # Start server for instance2instance communication Instance2InstanceServer( self.utility.read_config('i2ilistenport'), self.i2ithread_readlinecallback) self.splash.tick('GUIUtility register') self.guiUtility.register() self.frame = MainFrame( self, None, PLAYBACKMODE_INTERNAL in return_feasible_playback_modes(), self.splash.tick) self.frame.SetIcon( wx.Icon( os.path.join(self.installdir, 'Tribler', 'Main', 'vwxGUI', 'images', 'tribler.ico'), wx.BITMAP_TYPE_ICO)) # Arno, 2011-06-15: VLC 1.1.10 pops up separate win, don't have two. self.frame.videoframe = None if PLAYBACKMODE_INTERNAL in return_feasible_playback_modes(): vlcwrap = s.lm.videoplayer.get_vlcwrap() wx.CallLater(3000, vlcwrap._init_vlc) self.frame.videoframe = VideoDummyFrame( self.frame.videoparentpanel, self.utility, vlcwrap) if sys.platform == 'win32': wx.CallAfter(self.frame.top_bg.Refresh) wx.CallAfter(self.frame.top_bg.Layout) else: self.frame.top_bg.Layout() # Arno, 2007-05-03: wxWidgets 2.8.3.0 and earlier have the MIME-type for .bmp # files set to 'image/x-bmp' whereas 'image/bmp' is the official one. try: bmphand = None hands = wx.Image.GetHandlers() for hand in hands: # print "Handler",hand.GetExtension(),hand.GetType(),hand.GetMimeType() if hand.GetMimeType() == 'image/x-bmp': bmphand = hand break # wx.Image.AddHandler() if bmphand is not None: bmphand.SetMimeType('image/bmp') except: # wx < 2.7 don't like wx.Image.GetHandlers() print_exc() self.splash.Destroy() self.frame.Show(True) session.lm.threadpool.call_in_thread( 0, self.guiservthread_free_space_check) self.torrentfeed = RssParser.getInstance() self.webUI = None if self.utility.read_config('use_webui'): try: from Tribler.Main.webUI.webUI import WebUI self.webUI = WebUI.getInstance( self.guiUtility.library_manager, self.guiUtility.torrentsearch_manager, self.utility.read_config('webui_port')) self.webUI.start() except Exception: print_exc() self.emercoin_mgr = None try: from Tribler.Main.Emercoin.EmercoinMgr import EmercoinMgr self.emercoin_mgr = EmercoinMgr(self.utility) except Exception: print_exc() wx.CallAfter(self.PostInit2) # 08/02/10 Boudewijn: Working from home though console # doesn't allow me to press close. The statement below # gracefully closes Tribler after 120 seconds. # wx.CallLater(120*1000, wx.GetApp().Exit) self.ready = True except Exception as e: if self.splash: self.splash.Destroy() self.onError(e)
def OnBFpgaUploadButton(self, event): """ Event handler for the FPGA upload button """ # Ensure a module is selected and we have a valid file qusb = self.TheFrame.GetSelectedModule() if not qusb or not os.path.isfile(self.tbFpgaFileName.GetValue()): return # Initialize variables ok = True configured = False # Disable the upload button so that it is not clicked while we are # programming self.bFpgaUpload.Enable(False) # Open FPGA file try: fin = open(self.tbFpgaFileName.GetValue(), 'rb') except: ok = False # If we couldn't open the file, quit if not ok: return # Determine file length start = fin.tell() fin.seek(0, 2) end = fin.tell() fin.seek(0, 0) bytes = end - start # Setup the progress bar self.TheFrame.gProgress.SetRange(bytes) self.TheFrame.gProgress.SetValue(0) # As this is potentially a slow process, set the mouse cursor to busy wx.BeginBusyCursor() # We are going to write the FPGA data in 64 byte chucks (the maximum # allowed as documented in the QuickUSB User Guide). We first need to # create a data buffer to hold the data. buffer = CreateByteBuffer(64) # Start the configuration (ok, ) = qusb.StartFpgaConfiguration() if not ok: self.TheFrame.SetStatus( "StartFpgaConfiguration() failed with error: " + str(Error(qusb.LastError()))) # Display a message to the user wx.MessageBox( "Unable to start FPGA configuration. Please ensure that the FPGA is both powered and connected to the QuickUSB Module.", "FPGA Error") # Re-enable the upload button self.bFpgaUpload.Enable() # Close the file fin.close() fin = None # We must restore the cursor wx.EndBusyCursor() return # Loop through all the data in the file for k in xrange(0, bytes, 64): # Read 64 bytes of data from the file data = fin.read(64) # File reads always return python arrays, but we need to use our own # buffer so we must copy the data over for j in xrange(len(data)): buffer[j] = ord(data[j]) # Now, write the 64 bytes to the FPGA (ok, ) = qusb.WriteFpgaData(buffer, len(data)) if not ok: self.TheFrame.SetStatus("WriteFpgaData() failed with error: " + str(Error(qusb.LastError()))) # Re-enable the upload button self.bFpgaUpload.Enable() # Close the file fin.close() fin = None # We must restore the cursor wx.EndBusyCursor() return # Update the progress bar self.TheFrame.gProgress.SetValue(k + len(data)) # This is a slow process, so we should process GUI messages wx.Yield() # Close the file fin.close() fin = None # We must restore the cursor wx.EndBusyCursor() # Check if FPGA was successfully configured (ok, configured) = qusb.IsFpgaConfigured() if not ok: self.TheFrame.SetStatus("IsFpgaConfigured() failed with error: " + str(Error(qusb.LastError()))) return if not configured: self.TheFrame.gProgress.SetValue(0) self.TheFrame.SetStatus("FPGA configuration failed!") else: self.TheFrame.SetStatus("FPGA configuration succeeded!") # Re-enable the upload button self.bFpgaUpload.Enable() # Now that the programming is complete, sound the bell! wx.Bell() # Reset the progress bar, but wait a little first so the user can # really see that it hit 100% wx.CallLater(2000, self.TheFrame.gProgress.SetValue, 0)
build_dimensions = build_dimensions) gcode = gcoder.GCode(open(sys.argv[1]), get_home_pos(build_dimensions)) frame.addfile(gcode) first_move = None for i in range(len(gcode.lines)): if gcode.lines[i].is_move: first_move = gcode.lines[i] break last_move = None for i in range(len(gcode.lines) - 1, -1, -1): if gcode.lines[i].is_move: last_move = gcode.lines[i] break nsteps = 20 steptime = 500 lines = [first_move] + [gcode.lines[int(float(i) * (len(gcode.lines) - 1) / nsteps)] for i in range(1, nsteps)] + [last_move] current_line = 0 def setLine(): global current_line frame.set_current_gline(lines[current_line]) current_line = (current_line + 1) % len(lines) timer.Start() timer = wx.CallLater(steptime, setLine) timer.Start() frame.Show(True) app.MainLoop() app.Destroy()
def main(): a = testapp(plugins=False) f = wx.Frame(None, title='Popup Test', style=wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE, size=(400, 300)) f.CenterOnScreen() f.Bind(wx.EVT_CLOSE, lambda e: windowfx.fadeout(f)) f.Sizer = sz = wx.GridSizer(2, 2) if platformName == "win": from gui.native import process count_gdi_objects = process.count_gdi_objects def settitle(): f.Title = 'Popup Test (gdi: %s)' % count_gdi_objects() settitle() title_timer = wx.PyTimer(settitle) title_timer.Start(1000, False) from gui import skin service_icons = [ skin.get('serviceicons.' + srv) for srv in ('aim', 'icq', 'msn', 'yahoo', 'jabber', 'gtalk') ] for b in 'upperleft upperright lowerleft lowerright'.split(): button = wx.Button(f, -1, b) button.Bind( wx.EVT_BUTTON, lambda e, b=b: popup( position=b, badge=skin.get('serviceicons.facebook', None), header= 'header abcdefghijklmnopqrstuvwxyz djaflk dajlfk djaklf dsjaklf djakl', major='major', minor= 'minorfd jaklf jdkla fjkldwads fdjsa flkejw alfkd jsaklf jdsklafjdklsafjkl---wdq------------------fdasfsda------------fdasfdsa----fdasfdas---------------------------------------------------------------jdskla fjklsdaa jfkldwa jfkldsa jfklds ajklfds ajklfds ajklfds ajkl' )) sz.Add(button) class Target(object): def OnSave(self): print 'save' def OnSaveAs(self): print 'save as' def OnCancel(self): print 'cancel' target = Target() b = Button( f, 'with buttons', lambda: popup(position='lowerright', header='digsbyDragon', major='wants to send you file "digsby.zip"', buttons=[('Save', lambda: log.info('SAVE'))], target=target)) def input_cb(text, opts): print 'message:', text, opts def timed(): for x, msg in enumerate( 'lol roflmao brb afk jk wtf roflcopterz omg rusrs?'.split() * 3): wx.CallLater(1000 * x + 1, lambda msg=msg: popup(header='digsby', minor=msg, input=input_cb, popupid='wassup')) b2 = Button(f, 'with several inputs', timed) class Email(object): def __init__(self, subject, message): self.subject = subject self.message = message b3 = Button( f, 'with pages', lambda: popup( popupid=('a', 'b'), update='paged', position='lowerright', header='${email.subject}', major='${email.message}', pages='emails', emails=[ Email('test subject', 'test content'), Email('test subject 2', 'testcontent2') ], )) email_pages_args = dict( position='lowerright', header='${email.subject}', minor='${email.message}', pages='emails', emails=[ Email('test subject', 'test really long really long really ' * 10), Email('test subject 2', 'testcontent2') ], onclick=lambda a: log.info('wut')) b4 = Button(f, 'with pages', lambda: popup(**email_pages_args)) b5 = Button( f, 'after 2 secs', lambda: wx.CallLater( 2000, lambda: popup( position='lowerleft', header='${email.subject}', major='${email.message}', pages='emails', emails=[ Email('test subject', 'test content'), Email('test subject 2', 'testcontent2') ], ))) def prnt(*a): for f in a: print f, print def button_func(item): return [(item.email.subject, lambda *a, **k: prnt(item))] b11 = Button( f, 'multiple buttons', lambda: popup(position='lowerleft', header='${email.subject}', major='${email.message}', pages='emails', emails=[ Email('test subject', 'test content'), Email('test subject 2', 'testcontent2') ], buttons=button_func)) b9 = Button( f, 'new paged', lambda: popup(update='paged', header='blah', major='bleeh', minor='bluh', popupid='facebook.alerts')) from itertools import count count = count() def page_adder(position='lowerleft'): id = count.next() if id == 0: d = dict(major='${email.message}', minor='') else: d = dict(minor='${email.message}', major='') popup( position=position, header='${email.subject}', pages='emails', email=Email('test subject 2', 'content%d' % id), #update ='paged', popupid='add', onclick=lambda a: log.info('rawr %d', id), max_lines=20, **d) b6 = Button(f, 'add pages', page_adder) b6_2 = Button(f, 'add pages (top left)', lambda: page_adder('upperleft')) b7 = Button(f, 'show modal dialog', lambda: wx.MessageBox('modal!')) def many(): for x in xrange(3): popup(header='wut', major='major', minor='minor') b8 = Button(f, 'show many at once', many) def input_and_pages(): args = dict(email_pages_args) args.update(input=input_cb) popup(**args) def input_appends(): popup(input=lambda text, opts: '> ' + text, header='test', minor='minor', max_lines=5) b10 = Button(f, 'input + pages', input_and_pages) b12 = Button(f, 'input appends', input_appends) def input_after_buttons_popup(): buttons = [('test', input_callback(lambda **k: None))] popup(header='input after buttons', buttons=buttons) input_after_button = Button(f, 'input after button', input_after_buttons_popup) sz.AddMany((b, b2, b3, b4, b5, b6, b6_2, b7, b8, b9, b10, b11, b12)) sz.AddMany([ input_after_button, ]) sz.Add(wx.TextCtrl(f)) if hasattr(Popup, 'use_alphaborder'): use_alpha = wx.CheckBox(f, -1, 'use alphaborder') use_alpha.SetValue(Popup.use_alphaborder) use_alpha.Bind(wx.EVT_CHECKBOX, lambda e: setattr(Popup, 'use_alphaborder', e.Checked)) sz.Add(use_alpha) f.Bind(wx.EVT_CLOSE, lambda e: wx.GetApp().ExitMainLoop()) f.Show() a.MainLoop()
def __init__(self, parent, IDproduit=None, liste_produits=[], selection_multiple=False, selection_obligatoire=True): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX) self.parent = parent self.selection_multiple = selection_multiple self.selection_obligatoire = selection_obligatoire self.ctrl_produits = OL_Produits.ListView( self, id=-1, selection_multiple=selection_multiple, style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL | wx.LC_HRULES | wx.LC_VRULES) self.ctrl_produits.SetMinSize((750, 500)) self.ctrl_recherche = OL_Produits.CTRL_Outils( self, listview=self.ctrl_produits, afficherCocher=selection_multiple) self.check_disponibles = wx.CheckBox( self, -1, _(u"Afficher uniquement les produits disponibles")) self.check_disponibles.SetFont( wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)) self.check_disponibles.SetValue(True) self.bouton_aide = CTRL_Bouton_image.CTRL( self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_ok = CTRL_Bouton_image.CTRL( self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png") self.bouton_annuler = CTRL_Bouton_image.CTRL( self, id=wx.ID_CANCEL, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png") self.__set_properties() self.__do_layout() self.ctrl_produits.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok) self.Bind(wx.EVT_CHECKBOX, self.OnCheckDisponibles, self.check_disponibles) # Init contrôles self.ctrl_produits.coche_uniquement_disponibles = self.check_disponibles.GetValue( ) self.ctrl_produits.MAJ() if IDproduit == None and len(liste_produits) == 0: wx.CallLater(10, self.ctrl_recherche.SetFocus) else: if self.selection_multiple == False: self.ctrl_produits.SetID(IDproduit) else: self.ctrl_produits.SetListeProduits(liste_produits) wx.CallLater(10, self.ctrl_produits.SetFocus)
def __do_layout(self): grid_sizer_base = wx.FlexGridSizer(rows=4, cols=1, vgap=10, hgap=10) grid_sizer_base.Add(self.ctrl_bandeau, 0, wx.EXPAND, 0) box_parametres = wx.StaticBoxSizer(self.box_parametres_staticbox, wx.VERTICAL) grid_sizer_parametres = wx.FlexGridSizer(rows=3, cols=2, vgap=10, hgap=10) grid_sizer_parametres.Add(self.label_procedure, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_procedure = wx.FlexGridSizer(rows=1, cols=8, vgap=5, hgap=5) grid_sizer_procedure.Add(self.ctrl_procedure, 0, wx.EXPAND, 0) grid_sizer_procedure.Add(self.bouton_procedures, 0, 0, 0) grid_sizer_procedure.Add((10, 10), 0, 0, 0) grid_sizer_procedure.Add(self.label_date, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_procedure.Add(self.ctrl_date, 0, wx.EXPAND, 0) grid_sizer_procedure.Add((10, 10), 0, 0, 0) grid_sizer_procedure.Add(self.check_dateauto, 0, wx.EXPAND, 0) grid_sizer_procedure.AddGrowableCol(0) grid_sizer_parametres.Add(grid_sizer_procedure, 1, wx.EXPAND, 0) grid_sizer_parametres.AddGrowableCol(1) box_parametres.Add(grid_sizer_parametres, 1, wx.ALL | wx.EXPAND, 10) grid_sizer_base.Add(box_parametres, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10) # Log box_log = wx.StaticBoxSizer(self.box_log_staticbox, wx.VERTICAL) grid_sizer_log = wx.FlexGridSizer(rows=3, cols=2, vgap=5, hgap=5) grid_sizer_log.Add(self.ctrl_log, 1, wx.EXPAND, 0) # Commandes grid_sizer_log_commandes = wx.FlexGridSizer(rows=6, cols=1, vgap=5, hgap=5) grid_sizer_log_commandes.Add(self.bouton_log_apercu, 0, 0, 0) grid_sizer_log_commandes.Add(self.bouton_log_imprimer, 0, 0, 0) grid_sizer_log_commandes.Add((10, 10), 0, wx.EXPAND, 0) grid_sizer_log_commandes.Add(self.bouton_log_excel, 0, 0, 0) grid_sizer_log_commandes.Add(self.bouton_log_texte, 0, 0, 0) grid_sizer_log.Add(grid_sizer_log_commandes, 1, wx.EXPAND, 0) grid_sizer_log.Add(self.ctrl_recherche, 1, wx.EXPAND, 0) grid_sizer_log.Add((5, 5), 1, wx.EXPAND, 0) grid_sizer_log_options = wx.FlexGridSizer(rows=1, cols=6, vgap=5, hgap=5) grid_sizer_log_options.Add(self.hyper_consommations, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_log_options.Add(self.label_separation1, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_log_options.Add(self.hyper_journal, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_log_options.Add(self.label_separation2, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_log_options.Add(self.hyper_purger, 0, wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_log.Add(grid_sizer_log_options, 0, 0, 0) grid_sizer_log.AddGrowableRow(0) grid_sizer_log.AddGrowableCol(0) box_log.Add(grid_sizer_log, 1, wx.ALL | wx.EXPAND, 10) grid_sizer_base.Add(box_log, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10) # Boutons grid_sizer_boutons = wx.FlexGridSizer(rows=1, cols=6, vgap=10, hgap=10) grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0) grid_sizer_boutons.Add(self.bouton_vocal, 0, 0, 0) grid_sizer_boutons.Add(self.bouton_importation, 0, 0, 0) grid_sizer_boutons.Add((20, 20), 0, wx.EXPAND, 0) grid_sizer_boutons.Add(self.bouton_ok, 0, 0, 0) grid_sizer_boutons.Add(self.bouton_fermer, 0, 0, 0) grid_sizer_boutons.AddGrowableCol(3) grid_sizer_base.Add(grid_sizer_boutons, 1, wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10) self.SetSizer(grid_sizer_base) grid_sizer_base.Fit(self) grid_sizer_base.AddGrowableRow(2) grid_sizer_base.AddGrowableCol(0) self.Layout() self.CenterOnScreen() wx.CallLater(0, self.Layout) # Contre pb d'affichage du wx.Choice
def __init__(self): self.browser = None # Must ignore X11 errors like 'BadWindow' and others by # installing X11 error handlers. This must be done after # wx was intialized. if LINUX: cef.WindowUtils.InstallX11ErrorHandlers() global g_count_windows g_count_windows += 1 if WINDOWS: # noinspection PyUnresolvedReferences, PyArgumentList print("[wxpython.py] System DPI settings: %s" % str(cef.DpiAware.GetSystemDpi())) if hasattr(wx, "GetDisplayPPI"): print("[wxpython.py] wx.GetDisplayPPI = %s" % wx.GetDisplayPPI()) print("[wxpython.py] wx.GetDisplaySize = %s" % wx.GetDisplaySize()) print("[wxpython.py] MainFrame declared size: %s" % str( (WIDTH, HEIGHT))) size = scale_window_size_for_high_dpi(WIDTH, HEIGHT) print("[wxpython.py] MainFrame DPI scaled size: %s" % str(size)) wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, title='wxPython example', size=size) # wxPython will set a smaller size when it is bigger # than desktop size. print("[wxpython.py] MainFrame actual size: %s" % self.GetSize()) self.setup_icon() self.create_menu() self.Bind(wx.EVT_CLOSE, self.OnClose) # Set wx.WANTS_CHARS style for the keyboard to work. # This style also needs to be set for all parent controls. self.browser_panel = wx.Panel(self, style=wx.WANTS_CHARS) self.browser_panel.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) self.browser_panel.Bind(wx.EVT_SIZE, self.OnSize) if MAC: # Make the content view for the window have a layer. # This will make all sub-views have layers. This is # necessary to ensure correct layer ordering of all # child views and their layers. This fixes Window # glitchiness during initial loading on Mac (Issue #371). NSApp.windows()[0].contentView().setWantsLayer_(True) if LINUX: # On Linux must show before embedding browser, so that handle # is available (Issue #347). self.Show() # In wxPython 3.0 and wxPython 4.0 on Linux handle is # still not yet available, so must delay embedding browser # (Issue #349). if wx.version().startswith("3.") or wx.version().startswith("4."): wx.CallLater(100, self.embed_browser) else: # This works fine in wxPython 2.8 on Linux self.embed_browser() else: self.embed_browser() self.Show()
def InitView(self): if self._options['password'] is not None: self.pub('splash_set_status_text', 'waiting for password') def wx_code_password(): while True: with wx.PasswordEntryDialog(self._splash, 'Enter your password', 'Enter password') as dlg: if dlg.ShowModal() == wx.ID_OK: if hashlib.sha256(dlg.GetValue()).digest( ) == self._options['password']: break else: raise HydrusExceptions.PermissionException( 'Bad password check') self.CallBlockingToWx(wx_code_password) self.pub('splash_set_title_text', 'booting gui...') def wx_code_gui(): self._gui = ClientGUI.FrameGUI(self) # this is because of some bug in wx C++ that doesn't add these by default wx.richtext.RichTextBuffer.AddHandler( wx.richtext.RichTextHTMLHandler()) wx.richtext.RichTextBuffer.AddHandler( wx.richtext.RichTextXMLHandler()) self.ResetIdleTimer() self.CallBlockingToWx(wx_code_gui) HydrusController.HydrusController.InitView(self) self._local_service = None self._booru_service = None self.RestartServer() self.RestartBooru() if not self._no_daemons: self._daemons.append( HydrusThreading.DAEMONWorker( self, 'CheckMouseIdle', ClientDaemons.DAEMONCheckMouseIdle, period=10)) self._daemons.append( HydrusThreading.DAEMONWorker( self, 'DownloadFiles', ClientDaemons.DAEMONDownloadFiles, ('notify_new_downloads', 'notify_new_permissions'))) self._daemons.append( HydrusThreading.DAEMONWorker( self, 'SynchroniseAccounts', ClientDaemons.DAEMONSynchroniseAccounts, ('permissions_are_stale', ))) self._daemons.append( HydrusThreading.DAEMONWorker( self, 'SynchroniseSubscriptions', ClientDaemons.DAEMONSynchroniseSubscriptions, ('notify_restart_subs_sync_daemon', 'notify_new_subscriptions'))) self._daemons.append( HydrusThreading.DAEMONBigJobWorker( self, 'CheckImportFolders', ClientDaemons.DAEMONCheckImportFolders, ('notify_restart_import_folders_daemon', 'notify_new_import_folders'), period=180)) self._daemons.append( HydrusThreading.DAEMONBigJobWorker( self, 'CheckExportFolders', ClientDaemons.DAEMONCheckExportFolders, ('notify_restart_export_folders_daemon', 'notify_new_export_folders'), period=180)) self._daemons.append( HydrusThreading.DAEMONBigJobWorker( self, 'MaintainTrash', ClientDaemons.DAEMONMaintainTrash, init_wait=60)) self._daemons.append( HydrusThreading.DAEMONBigJobWorker( self, 'RebalanceClientFiles', ClientDaemons.DAEMONRebalanceClientFiles, period=3600)) self._daemons.append( HydrusThreading.DAEMONBigJobWorker( self, 'SynchroniseRepositories', ClientDaemons.DAEMONSynchroniseRepositories, ('notify_restart_repo_sync_daemon', 'notify_new_permissions'), period=4 * 3600)) self._daemons.append( HydrusThreading.DAEMONBigJobWorker( self, 'UPnP', ClientDaemons.DAEMONUPnP, ('notify_new_upnp_mappings', ), init_wait=120, pre_callable_wait=6)) self._daemons.append( HydrusThreading.DAEMONQueue( self, 'FlushRepositoryUpdates', ClientDaemons.DAEMONFlushServiceUpdates, 'service_updates_delayed', period=5)) if HydrusGlobals.is_first_start: wx.CallAfter(self._gui.DoFirstStart) if HydrusGlobals.is_db_updated: wx.CallLater( 1, HydrusData.ShowText, 'The client has updated to version ' + str(HC.SOFTWARE_VERSION) + '!')
def pollServer(self): self.Tally() wx.CallLater(500, self.pollServer)
def OnEnterWindow(self, event): if self._mainframe_has_focus(): self.popup_timer = wx.CallLater(500, self.OnPopupTimer, event)
def Flash(self, couleur=None): self.MAJ(couleur) wx.CallLater(1000, self.MAJ, self.couleurInitiale)
def Blink(self): self.HighLight(0.15) wx.CallLater(300, self.HighLight, 0.15)
def loadBuffer(self): self.isLoading = True self._loadProgressCallLater = wx.CallLater(1000, self._loadProgress) threading.Thread(target=self._loadBuffer).start()