Exemple #1
0
    def onReload_set_selections(self, ev_selections):

        self.choiceCategoricalList = []
        self.choiceDemeanList = []

        for cb_id in self.cbValuesDict.keys():

            cb_name = self.cbValuesDict[cb_id][0]

            if 'categorical' in ev_selections.keys():

                if (cb_name
                        in ev_selections['categorical']) and (cb_id % 2 != 0):

                    cb = wx.FindWindowById(cb_id)
                    cb.SetValue(True)

                    self.choiceCategoricalList.append(cb_name)

            if 'demean' in ev_selections.keys():

                if (cb_name in ev_selections['demean']) and (cb_id % 2 == 0):

                    cb = wx.FindWindowById(cb_id)
                    cb.SetValue(True)

                    self.choiceDemeanList.append(cb_name)

        self.choiceDict['categorical'] = self.choiceCategoricalList
        self.choiceDict['demean'] = self.choiceDemeanList
Exemple #2
0
    def record_single_coord(self, event):
        '''Function for recording a single coordinate'''
        num_id = self.first_coord.GetId()
        x = wx.FindWindowById(num_id + 1)
        y = wx.FindWindowById(num_id + 2)

        cursorpos = GetCursorPos()

        def stop_record():
            '''Sub-function for resetting label color and stopping recording'''
            self.first_coord.SetForegroundColour("black")
            self.first_coord.Refresh()
            self.stop_record()

        if self.movement_relative.GetValue():
            # Set origin point for relative coordinates
            if not self.last_coord:
                self.last_coord = cursorpos
            else:
                # Input coordinates in list (relative to origin point)
                for i, widget in enumerate([x, y]):
                    widget.SetValue(cursorpos[i] - self.last_coord[i])
                stop_record()
        else:
            # Input cursor position in list (absolute coordinates)
            for i, widget in enumerate([x, y]):
                widget.SetValue(cursorpos[i])
            stop_record()

        return True
Exemple #3
0
 def __init__(self, parent, deactivate, post_apply=lambda *args: 0):
     try:
         super(BrlIMEHelperSettingsDialog,
               self).__init__(parent, hasApplyButton=True)
     except:
         super(BrlIMEHelperSettingsDialog, self).__init__(parent)
     self.deactivate, self.post_apply = deactivate, post_apply
     apply_button = wx.FindWindowById(wx.ID_APPLY, self)
     if apply_button is None:
         log.debug(
             "Try to reconstruct buttons in the bottom right corner for NVDA versions earlier than 2018.2."
         )
         ok_button = wx.FindWindowById(wx.ID_OK, self)
         cancel_button = wx.FindWindowById(wx.ID_CANCEL, self)
         assert (ok_button.GetParent() is cancel_button.GetParent())
         mainSizer = ok_button.GetParent().GetSizer()
         if mainSizer.Remove(
                 2
         ):  # The sizer containing [OK] and [Cancel] buttons is removed.
             ok_button.Destroy()
             cancel_button.Destroy()
             mainSizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL
                                                  | wx.APPLY),
                           border=guiHelper.BORDER_FOR_DIALOGS,
                           flag=wx.ALL | wx.ALIGN_RIGHT)
             mainSizer.Fit(self)
         self.postInit()
     self.Bind(wx.EVT_BUTTON, self.onApply, id=wx.ID_APPLY)
Exemple #4
0
 def set_cursor_on_objects(self, cursor):
     obj = wx.FindWindowById(0, )
     i = 0
     while obj is not None:
         obj.SetCursor(cursor)
         i += 1
         obj = wx.FindWindowById(i)
 def add_emoji(self, message):
     emoji_code_list = message.split(';')
     for j in range(len(emoji_code_list)):
         self.bag_of_emoji_code.pop()
     for code in emoji_code_list:
         self.bag_of_emoji_code.insert(0, code)
     for i, bag_emoji in enumerate(
             zip(self.bag_of_emoji_code, self.bag_of_emoji_pos)):
         wx.FindWindowById(i + 12).Destroy()
         code, pos = bag_emoji
         #code = int(code, base=16)
         #emoji_lb = wx.Button(self, i + 12, chr(code), size=(24, 24), pos=pos)
         selected = list(
             filter(lambda x: x if code in x else None, self.emoji_bank))
         em_im = wx.Image(os.path.join('emoji_apple', selected[0]),
                          wx.BITMAP_TYPE_ANY).Scale(24,
                                                    24).ConvertToBitmap()
         wx.BitmapButton(self,
                         i + 12,
                         em_im,
                         size=(24, 24),
                         pos=pos,
                         style=wx.NO_BORDER)
     for i in range(len(self.bag_of_emoji_code)):
         self.Bind(wx.EVT_BUTTON,
                   lambda evt, mark=self.bag_of_emoji_code[i]: self.
                   OnPasteEmoji(evt, mark),
                   wx.FindWindowById(i + 12))
Exemple #6
0
    def delete_coords(self, event):
        '''Function for deleting an already existing coordinate'''
        if self.motionctrl.GetEffectiveRowsCount() > 2:
            obj = event.GetEventObject()

            # Collecting all widgets to be deleted
            delete_widgets = [
                wx.FindWindowById(obj.GetId() - i)
                for i in range(self.motionctrl.GetCols())
            ]

            # Updating coordinate numbers
            all_ids = sorted([
                child.GetWindow().GetId()
                for child in self.motionctrl.GetChildren()
            ])
            for x in all_ids[all_ids.index(delete_widgets[-1].GetId())::5][1:]:
                widget = wx.FindWindowById(x)
                widget.SetLabel(str(int(widget.GetLabel()[0]) - 1) + ")")

            # Removing coordinate from list
            self.coordinates.pop(int(delete_widgets[-1].GetLabel()[0]) - 1)

            # Destroying all widgets related to the deleted coordinate
            for widget in delete_widgets:
                widget.Destroy()
            self.motionctrl.Layout()

            # Saving settings
            self.save_profile(None)
Exemple #7
0
    def SetButtonSizer(self, sizer):
        self.GetSizer().Add(sizer, 0, wx.EXPAND | wx.BOTTOM | wx.RIGHT,
                            self.GetDialogBorder())

        # Temporary hack to fix button ordering problems.
        cancel = wx.FindWindowById(wx.ID_CANCEL, parent=self)
        no = wx.FindWindowById(wx.ID_NO, parent=self)
        if no and cancel:
            cancel.MoveAfterInTabOrder(no)
Exemple #8
0
    def AddObjects(self,
                   obKeys,
                   chMap=None,
                   priority=1,
                   pos='first',
                   display_whole_image=False,
                   srcID=None):
        if chMap is None:
            chMap = p.image_channel_colors
        if self.tile_collection == None:
            self.tile_collection = tilecollection.TileCollection()
        if srcID is not None and isinstance(wx.FindWindowById(srcID), SortBin):
            source = wx.FindWindowById(srcID)
            for tile in source.tiles[::-1]:
                if tile.obKey in obKeys and tile.selected:
                    source.tiles.remove(tile)
                    source.sizer.Detach(tile)
                    tile.Reparent(self)
                    tile.bin = self
                    if pos == 'first':
                        self.tiles.insert(0, tile)
                        self.sizer.Insert(0, tile, 0, wx.ALL | wx.EXPAND, 1)
                    else:
                        self.tiles.append(tile)
                        self.sizer.Add(tile, 0, wx.ALL | wx.EXPAND, 1)
            source.UpdateSizer()
            source.UpdateQuantity()
        else:
            imgSet = self.tile_collection.GetTiles(
                obKeys, (self.classifier or self),
                priority,
                display_whole_image=display_whole_image
            )  # Gives back the np matrix of an image?
            for i, obKey, imgs in zip(list(range(len(obKeys))), obKeys,
                                      imgSet):
                if self.classifier:
                    newTile = ImageTile(self,
                                        obKey,
                                        imgs,
                                        chMap,
                                        False,
                                        scale=self.classifier.scale,
                                        brightness=self.classifier.brightness,
                                        contrast=self.classifier.contrast)

                else:
                    newTile = ImageTile(self, obKey, imgs, chMap, False)

                if pos == 'first':
                    self.tiles.insert(i, newTile)
                    self.sizer.Insert(i, newTile, 0, wx.ALL | wx.EXPAND, 1)
                else:
                    self.tiles.append(newTile)
                    self.sizer.Add(newTile, 0, wx.ALL | wx.EXPAND, 1)
        self.UpdateSizer()
        self.UpdateQuantity()
Exemple #9
0
def destroy_objects():
    '''
      destory all the objects with consecutive IDs
    '''
    obj = wx.FindWindowById(0)
    i = 0
    while obj is not None:
        obj.Destroy()
        i += 1
        obj = wx.FindWindowById(i)
Exemple #10
0
 def getOptions(mbt):
     result = buttonsArr[buttonsCtrl.GetSelection()]
     result += iconArr[iconCtrl.GetSelection()]
     if not mbt:
         result += optionsArr[wx.FindWindowById(ids[0]).GetSelection()]
     else:
         tmp = wx.FindWindowById(ids[0]).GetValue()   + \
             2 * wx.FindWindowById(ids[1]).GetValue() + \
             4 * wx.FindWindowById(ids[2]).GetValue()
         result += 4096 * tmp
     return result
Exemple #11
0
 def move(self, event):
     self.Destroy()
     moni_on = get_val('moni_on')
     moni_webframe = get_val('moni_webframe')
     guopai_webframe = get_val('guopai_webframe')
     if moni_on:
         moni = wx.FindWindowById(moni_webframe)
         moni.SetFocus()
     else:
         guopai = wx.FindWindowById(guopai_webframe)
         guopai.SetFocus()
Exemple #12
0
    def enableAllChecks(self, event):
        if self.ck_EnableAll.Value == True:
            self.ck_EnableAll.Label = "Disable All"
        else:
            self.ck_EnableAll.Label = "Enable All"

        for item in range(len(list_checkboxID)):
            if wx.FindWindowById(
                    list_checkboxID[item]).Label != "<add database>":
                wx.FindWindowById(
                    list_checkboxID[item]).Value = self.ck_EnableAll.Value
        self.buildLaunch()
Exemple #13
0
 def find_items(self, event):
     for tuple in self.view.ids:
         for id in tuple:
             if id == event.GetId():
                 i = self.view.ids.index(tuple)  # 0=ov1, 1=ov2, 2=base
                 cb = wx.FindWindowById(tuple[0])
                 tc = wx.FindWindowById(tuple[1])
                 s = wx.FindWindowById(tuple[2])
     if type(wx.FindWindowById(event.GetId())) == wx._controls.CheckBox:
         self.on_checkbox(i, cb, tc, s)
     elif type(wx.FindWindowById(event.GetId())) == wx._controls.TextCtrl:
         self.on_text_ctrl(i, tc, s)
     self.on_slider(i, s, tc)
Exemple #14
0
    def onCheck_UpdateValue(self, event):  #, idNum):

        # somehow take in the self.cbValuesDict[idx] (name, column, value)
        # and then GetValue from all idx, and update value for that idx

        # then have another function which returns this entire dict

        self.choiceCategoricalList = []
        self.choiceDemeanList = []

        for idNum in range(101, self.maxIDNum):

            self.cbValuesDict[idNum][2] = wx.FindWindowById(idNum).GetValue()

        for idNum in range(101, self.maxIDNum):

            if self.cbValuesDict[idNum][1] == 'categorical':

                if self.cbValuesDict[idNum][2] == True:
                    self.choiceCategoricalList.append(
                        self.cbValuesDict[idNum][0])

                    if ('demean', idNum + 1) not in self.tempChoiceDict.keys():
                        self.tempChoiceDict[(
                            'demean', idNum +
                            1)] = wx.FindWindowById(idNum + 1).GetValue()

                    wx.FindWindowById(idNum + 1).Set3StateValue(
                        2)  # set demean to N/A

                else:
                    #self.choiceCategoricalList.append('0')

                    #wx.FindWindowById(idNum+1).Set3StateValue(0)  # undo demean as N/A
                    if ('demean', idNum + 1) in self.tempChoiceDict.keys():
                        wx.FindWindowById(idNum + 1).SetValue(
                            self.tempChoiceDict[('demean', idNum + 1)])
                        del self.tempChoiceDict[('demean', idNum + 1)]
                        #wx.FindWindowById(idNum+1).Set3StateValue(0)  # undo demean as N/A
                        #wx.FindWindowById(idNum+1).SetValue(self.tempChoiceDict[('demean',idNum+1)])

            elif self.cbValuesDict[idNum][1] == 'demean':

                if self.cbValuesDict[idNum][2] == True:
                    self.choiceDemeanList.append(self.cbValuesDict[idNum][0])
                #else:
                #self.choiceDemeanList.append('0')

        self.choiceDict['categorical'] = self.choiceCategoricalList
        self.choiceDict['demean'] = self.choiceDemeanList
 def DEFAULT_ERROR(self, response, sizer):
     '''Using a default error message'''
     
     for widget in sizer.GetChildren():
         window = widget.GetWindow()
         if window.GetClassName() == "wxStaticText" and window.GetLabel().lower().strip(":") in errormessages[response][1]:
             self.SHOW_ERRORMSG(errormessages[response][0], wx.FindWindowById(window.GetId() + 1))
Exemple #16
0
 def callback(saveas_id, infohash):
     saveas = wx.FindWindowById(saveas_id)
     if saveas:
         tdef = TorrentDef.load_from_memory(
             self.utility.session.lm.torrent_store.get(infohash))
         event = CollectedEvent(tdef=tdef)
         wx.PostEvent(saveas, event)
Exemple #17
0
 def __init__(self, parent, id, title):
     super(OptionsDialog, self).__init__(parent, id, title=title)
     main_sizer = wx.BoxSizer(wx.VERTICAL)
     # Translators: A radiobutton group in add-on options dialog to choose if autoconnecting is disabled, connects to a self-hosted server, or to an external control server, in that order.
     self.autoconnect = wx.RadioBox(
         self,
         wx.ID_ANY,
         choices=(_("Don't autoconnect"),
                  _("Autoconnect to a self-hosted server"),
                  _("Autoconnect to an external control server")),
         style=wx.RA_VERTICAL)
     self.autoconnect.Bind(wx.EVT_RADIOBOX, self.on_autoconnect)
     main_sizer.Add(self.autoconnect)
     main_sizer.Add(wx.StaticText(self, wx.ID_ANY, label=_("&Host:")))
     self.host = wx.TextCtrl(self, wx.ID_ANY)
     self.host.Enable(False)
     main_sizer.Add(self.host)
     main_sizer.Add(wx.StaticText(self, wx.ID_ANY, label=_("&Key:")))
     self.key = wx.TextCtrl(self, wx.ID_ANY)
     self.key.Enable(False)
     main_sizer.Add(self.key)
     buttons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
     main_sizer.Add(buttons, flag=wx.BOTTOM)
     main_sizer.Fit(self)
     self.SetSizer(main_sizer)
     ok = wx.FindWindowById(wx.ID_OK, self)
     ok.Bind(wx.EVT_BUTTON, self.on_ok)
     self.autoconnect.SetFocus()
Exemple #18
0
 def __init__(self, parent, id, title):
     super(DirectConnectDialog, self).__init__(parent, id, title=title)
     main_sizer = self.main_sizer = wx.BoxSizer(wx.VERTICAL)
     self.client_or_server = wx.RadioBox(self,
                                         wx.ID_ANY,
                                         choices=(_("Client"), _("Server")),
                                         style=wx.RA_VERTICAL)
     self.client_or_server.Bind(wx.EVT_RADIOBOX, self.on_client_or_server)
     self.client_or_server.SetSelection(0)
     main_sizer.Add(self.client_or_server)
     choices = [
         _("Control another machine"),
         _("Allow this machine to be controlled")
     ]
     self.connection_type = wx.RadioBox(self,
                                        wx.ID_ANY,
                                        choices=choices,
                                        style=wx.RA_VERTICAL)
     self.connection_type.SetSelection(0)
     main_sizer.Add(self.connection_type)
     self.container = wx.Panel(parent=self)
     self.panel = ClientPanel(parent=self.container)
     main_sizer.Add(self.container)
     buttons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
     main_sizer.Add(buttons, flag=wx.BOTTOM)
     main_sizer.Fit(self)
     self.SetSizer(main_sizer)
     ok = wx.FindWindowById(wx.ID_OK, self)
     ok.Bind(wx.EVT_BUTTON, self.on_ok)
Exemple #19
0
    def OnCopy(self, event):
        # Copy the lib/footprint for the selected footprint onto the clipboard.

        # Get the cell where the cursor is.
        # row = self.found_footprints.GetGridCursorRow()
        try:
            row = self.found_footprints.GetSelectedRows()[0]
        except (IndexError, TypeError):
            return

        # Deselect all rows but the first.
        self.found_footprints.SelectRow(row)

        # Create a SKiDL part instantiation.
        lib = self.found_footprints.GetCellValue(row, 0)
        footprint = self.found_footprints.GetCellValue(row, 1)
        footprint_inst = "footprint='{lib}:{footprint}'".format(**locals())

        # Make a data object to hold the SKiDL part instantiation.
        dataObj = wx.TextDataObject()
        dataObj.SetText(footprint_inst)

        # Place the SKiDL part instantiation on the clipboard.
        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(dataObj)
            wx.TheClipboard.Flush()
        else:
            Feedback("Unable to open clipboard!", "Error")

        # Create search string for part footprint.
        evt = SendFootprintEvent(footprint=footprint_inst)
        wx.PostEvent(wx.FindWindowById(PART_PANEL_ID), evt)
Exemple #20
0
 def on_slider(self, i, s, tc):
     self.alphas[i] = s.GetValue()
     tc.SetValue(str(self.alphas[i]) + '%')
     if self.alphas[0] + self.alphas[1] > 100:
         if i == 0:
             self.alphas[i+1] = 100 - self.alphas[i]
             wx.FindWindowById(self.view.ids[i+1][1]).SetValue(str(self.alphas[i+1])+'%')
             wx.FindWindowById(self.view.ids[i+1][2]).SetValue(self.alphas[i+1])
         else:
             self.alphas[i-1] = 100- self.alphas[i]
             wx.FindWindowById(self.view.ids[i-1][1]).SetValue(str(self.alphas[i-1])+'%')
             wx.FindWindowById(self.view.ids[i-1][2]).SetValue(self.alphas[i-1])
             
         self.alphas[2] = 100 - (self.alphas[0] + self.alphas[1])
     else:
         self.alphas[2] = 100 - (self.alphas[0] + self.alphas[1])
Exemple #21
0
 def __init__(self, parent, id, title):
     super(OptionsDialog, self).__init__(parent, id, title=title)
     main_sizer = wx.BoxSizer(wx.VERTICAL)
     # Translators: A checkbox in add-on options dialog to set whether remote server is started when NVDA starts.
     self.autoconnect = wx.CheckBox(
         self,
         wx.ID_ANY,
         label=_("Auto-connect to control server on startup"))
     self.autoconnect.Bind(wx.EVT_CHECKBOX, self.on_autoconnect)
     main_sizer.Add(self.autoconnect)
     main_sizer.Add(wx.StaticText(self, wx.ID_ANY, label=_("&Host:")))
     self.host = wx.TextCtrl(self, wx.ID_ANY)
     self.host.Enable(False)
     main_sizer.Add(self.host)
     main_sizer.Add(wx.StaticText(self, wx.ID_ANY, label=_("&Key:")))
     self.key = wx.TextCtrl(self, wx.ID_ANY)
     self.key.Enable(False)
     main_sizer.Add(self.key)
     buttons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
     main_sizer.Add(buttons, flag=wx.BOTTOM)
     main_sizer.Fit(self)
     self.SetSizer(main_sizer)
     ok = wx.FindWindowById(wx.ID_OK, self)
     ok.Bind(wx.EVT_BUTTON, self.on_ok)
     self.autoconnect.SetFocus()
Exemple #22
0
    def on_close(self, evt=None):
        # Classifier needs to be told to close so it can clean up it's threads
        classifier = wx.FindWindowById(ID_CLASSIFIER) or wx.FindWindowByName(
            'Classifier')
        if classifier and classifier.Close() == False:
            return

        if any(wx.GetApp().get_plots()):
            dlg = wx.MessageDialog(
                self,
                'Some tools are open, are you sure you want to quit CPA?',
                'Quit CellProfiler Analyst?',
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
            response = dlg.ShowModal()
            if response != wx.ID_YES:
                return

        try:
            logging.debug("Shutting of Java VM")
            import javabridge
            if javabridge.get_env() is not None:
                javabridge.kill_vm()
        except:
            logging.debug("Failed to kill the Java VM")

        # Blow up EVVVVERYTHIIINGGG!!! Muahahahahhahahah!
        for win in wx.GetTopLevelWindows():
            logging.debug('Destroying: %s' % (win))
            win.Destroy()
        if self.tbicon is not None:
            self.tbicon.Destroy()

        self.Destroy()
Exemple #23
0
    def OnButton(self, evt):
        """Handles button events
        @param evt: event that called this handler
        @postcondition: Dialog is closed
        @postcondition: If Report Event then email program is opened

        """
        e_id = evt.GetId()
        if e_id == wx.ID_CLOSE:
            self.Close()
        elif e_id == ID_SEND:
            status, error = send_email_via_webbrowser(
                "%s Error Report" % self.task.about_title, self.err_msg,
                self.task.error_email_to)
            if status:
                self.Close()
            else:
                self._panel.text.AppendText(error)
                btn = wx.FindWindowById(ID_SEND, self)
                btn.Enable(False)
        elif e_id == wx.ID_ABORT:
            ErrorDialog.ABORT = True
            # Try a nice shutdown first time through
            app = wx.GetApp()
            for tlw in wx.GetTopLevelWindows():
                tlw.Destroy()

            wx.CallLater(500, app.ExitMainLoop)
            self.Close()
        elif e_id == wx.ID_IGNORE:
            self.user_requested_ignore[self._message] = True
            self.Close()
        else:
            evt.Skip()
Exemple #24
0
    def OnCopy(self, event):
        # Copy the lib/part for the selected part onto the clipboard.

        # Get the cell where the cursor is.
        row = self.found_parts.GetGridCursorRow()

        # Deselect all rows but the first.
        self.found_parts.SelectRow(row)

        # Create a SKiDL part instantiation without a footprint.
        lib = self.found_parts.GetCellValue(row, 0)
        part = self.found_parts.GetCellValue(row, 1)
        if self.template_ckbx.IsChecked():
            s = "Part(lib='{lib}', name='{part}', dest=TEMPLATE)"
        else:
            s = "Part(lib='{lib}', name='{part}')"
        self.part_inst = s.format(**locals())

        # Make a data object to hold the SKiDL part instantiation.
        dataObj = wx.TextDataObject()
        dataObj.SetText(self.part_inst)

        # Place the SKiDL part instantiation on the clipboard.
        wx.TheClipboard.Clear(
        )  # Prevents error about clipbrd already being open.
        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(dataObj)
            wx.TheClipboard.Close()  # Using Flush() causes error on linux.
        else:
            Feedback("Unable to open clipboard!", "Error")

        # Request the footprint panel to return whatever footprint is selected.
        # The footprint panel will respond with an event containing the footprint.
        evt = RequestFootprintEvent()
        wx.PostEvent(wx.FindWindowById(FOOTPRINT_PANEL_ID), evt)
Exemple #25
0
    def Run(self):

        if(not self.button_inited):
            #for i in range(20):
            #    print("\n")
            try:
                top_toolbar = wx.FindWindowById(ID_H_TOOLBAR, parent=self.findPcbnewWindow())

                path = os.path.dirname(os.path.realpath(__file__))

                PinSpektor_button = wx.NewId()
                PinSpektor_button_bm = wx.Bitmap(
                    os.path.join(path, "PinSpektor", "PinSpektor.png"),
                    wx.BITMAP_TYPE_PNG,
                )
                #debug_dialog(PinSpektor_button_bm)
                top_toolbar.AddTool(
                    PinSpektor_button,
                    "PinSpektor",
                    PinSpektor_button_bm,
                    "Inspect Pins",
                    wx.ITEM_NORMAL,
                )
                top_toolbar.Bind(wx.EVT_TOOL, PinSpektorPlugin.getPSD, id=PinSpektor_button)
            except Exception as e:
                debug_dialog("Something went wrong!", e)


            top_toolbar.Realize()
            self.button_inited = True  # Buttons now installed in toolbar.
            self.pin_inspecter = self.getPSD(self)
Exemple #26
0
    def __init__(self, old_stdout):
        wx.Dialog.__init__(self,
                           parent=wx.GetApp().TopWindow,
                           title="Console Output",
                           size=(500, 200),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        console_box = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY)
        sys.stdout = RedirectText(console_box, old_stdout)

        top_sizer = wx.BoxSizer(wx.VERTICAL)
        console_sizer = wx.BoxSizer(wx.VERTICAL)
        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)

        report_button = wx.FindWindowById(wx.ID_CANCEL, self)
        report_button.SetLabel("Report an issue")

        console_sizer.Add(console_box, 1,
                          wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ALIGN_TOP, 5)

        top_sizer.Add(console_sizer, 1, wx.ALL | wx.EXPAND, 5)
        top_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_LEFT, 5)

        self.Bind(wx.EVT_CLOSE, handler=lambda x: sys.exit(0))
        self.Bind(wx.EVT_BUTTON, handler=lambda x: sys.exit(0), id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON,
                  source=report_button,
                  handler=self.submit_issue)
        self.SetSizer(top_sizer)
 def OnButtonOnly(self, event, mark):
     btn = wx.FindWindowById(mark)
     if btn.GetValue() == True:
         for button in self.bag_of_buttons:
             button.SetValue(False)
         btn.SetValue(True)
         self.mode = self.dict_of_modes[btn]
Exemple #28
0
    def on_listbox_change(self, event):
        item_object = event.EventObject
        selection = item_object.get_key_from_index(item_object.GetSelection())
        description = translate_key(MODULE_KEY.join([selection,
                                                     'description']))

        item_key = modules.interface.controls.IDS[event.GetId()].split(
            MODULE_KEY)
        config_item_path = get_config_item_path(item_key[:-1])
        module_class = deep_get(self.main_class.loaded_modules,
                                *config_item_path)
        show_description = module_class.description

        if isinstance(item_object, KeyListBox):
            self.on_change(modules.interface.controls.IDS[event.GetId()],
                           selection,
                           item_type='listbox',
                           section=True)

        if show_description:
            item_id_key = MODULE_KEY.join(item_key[:-1])
            descr_static_text = wx.FindWindowById(
                modules.interface.controls.get_id_from_name(
                    MODULE_KEY.join([item_id_key, 'descr_explain'])))
            descr_static_text.SetLabel(description)
            descr_static_text.Wrap(descr_static_text.GetSize()[0])
Exemple #29
0
    def SetBarStyle(self, agwStyle):

        self._ribbon.Freeze()
        self._ribbon.SetAGWWindowStyleFlag(agwStyle)

        pTopSize = self.panel.GetSizer()
        pToolbar = wx.FindWindowById(ID_MAIN_TOOLBAR)

        if agwStyle & RB.RIBBON_BAR_FLOW_VERTICAL:

            self._ribbon.SetTabCtrlMargins(10, 10)
            pTopSize.SetOrientation(wx.HORIZONTAL)
            if pToolbar:
                pToolbar.SetRows(3, 5)

        else:

            self._ribbon.SetTabCtrlMargins(50, 20)
            pTopSize.SetOrientation(wx.VERTICAL)
            if pToolbar:
                pToolbar.SetRows(2, 3)

        self._ribbon.Realize()
        self._ribbon.Thaw()
        self.panel.Layout()
Exemple #30
0
 def onCheckBox(evt):
     ctrl1 = wx.FindWindowById(ids[1])
     val = evt.IsChecked()
     ctrl1.Enable(not val)
     if val:
         ctrl1.SetValue(True)
     evt.Skip()