Пример #1
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          title=wx.EmptyString,
                          pos=wx.DefaultPosition,
                          size=wx.Size(800, 600),
                          style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

        main_vbox = wx.BoxSizer(wx.VERTICAL)

        info_svbox = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, u"Visualization Options"),
            wx.VERTICAL)

        self.m_panel = wx.Panel(info_svbox.GetStaticBox(), wx.ID_ANY,
                                wx.DefaultPosition, wx.DefaultSize,
                                wx.TAB_TRAVERSAL)
        vbox_top = wx.BoxSizer(wx.VERTICAL)

        hbox_top = wx.BoxSizer(wx.HORIZONTAL)

        self.bl_info_st_name = wx.StaticText(
            self.m_panel, wx.ID_ANY, u"Selected Beamline:", wx.DefaultPosition,
            wx.DefaultSize, wx.ALIGN_LEFT)
        self.bl_info_st_name.Wrap(-1)
        hbox_top.Add(self.bl_info_st_name, 0, wx.ALL, 5)

        self.bl_info_st_val = wx.StaticText(self.m_panel, wx.ID_ANY,
                                            wx.EmptyString, wx.DefaultPosition,
                                            wx.DefaultSize, wx.ALIGN_LEFT)
        self.bl_info_st_val.Wrap(-1)
        self.bl_info_st_val.SetForegroundColour(wx.Colour(0, 0, 255))

        hbox_top.Add(self.bl_info_st_val, 0, wx.ALL, 5)

        vbox_top.Add(hbox_top, 1, wx.EXPAND, 5)

        hbox_bottom = wx.BoxSizer(wx.HORIZONTAL)

        mode_rbChoices = [u"plain", u"fancy"]
        self.mode_rb = wx.RadioBox(self.m_panel, wx.ID_ANY, u"Mode",
                                   wx.DefaultPosition, wx.DefaultSize,
                                   mode_rbChoices, 1, wx.RA_SPECIFY_COLS)
        self.mode_rb.SetSelection(1)
        hbox_bottom.Add(self.mode_rb, 1, wx.BOTTOM | wx.LEFT | wx.RIGHT, 5)

        annote_sb = wx.StaticBoxSizer(
            wx.StaticBox(self.m_panel, wx.ID_ANY, u"Tag Options"),
            wx.HORIZONTAL)

        self.quad_ckb = wx.CheckBox(annote_sb.GetStaticBox(), wx.ID_ANY,
                                    u"Quad", wx.DefaultPosition,
                                    wx.DefaultSize, 0)
        annote_sb.Add(self.quad_ckb, 0, wx.ALL, 5)

        self.bend_ckb = wx.CheckBox(annote_sb.GetStaticBox(), wx.ID_ANY,
                                    u"Bend", wx.DefaultPosition,
                                    wx.DefaultSize, 0)
        annote_sb.Add(self.bend_ckb, 0, wx.ALL, 5)

        self.rf_ckb = wx.CheckBox(annote_sb.GetStaticBox(), wx.ID_ANY, u"RF",
                                  wx.DefaultPosition, wx.DefaultSize, 0)
        annote_sb.Add(self.rf_ckb, 0, wx.ALL, 5)

        self.monitor_ckb = wx.CheckBox(annote_sb.GetStaticBox(), wx.ID_ANY,
                                       u"Monitor", wx.DefaultPosition,
                                       wx.DefaultSize, 0)
        annote_sb.Add(self.monitor_ckb, 0, wx.ALL, 5)

        self.undulator_ckb = wx.CheckBox(annote_sb.GetStaticBox(), wx.ID_ANY,
                                         u"Undulator", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        annote_sb.Add(self.undulator_ckb, 0, wx.ALL, 5)

        hbox_bottom.Add(annote_sb, 2, wx.ALIGN_TOP | wx.BOTTOM | wx.EXPAND |
                        wx.LEFT, 5)

        vbox_top.Add(hbox_bottom, 0, wx.EXPAND, 5)

        self.m_panel.SetSizer(vbox_top)
        self.m_panel.Layout()
        vbox_top.Fit(self.m_panel)
        info_svbox.Add(self.m_panel, 0, wx.ALIGN_CENTER | wx.ALL | wx.EXPAND,
                       5)

        main_vbox.Add(info_svbox, 0, wx.ALL | wx.EXPAND, 10)

        draw_svbox = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, u"Drawing"), wx.VERTICAL)

        draw_vbox = wx.BoxSizer(wx.VERTICAL)

        self.drawing_panel = pltutils.LatticePlotPanel(
            self, dpi=75, toolbar=True,
            type='image')
        draw_vbox.Add(self.drawing_panel, 1, wx.EXPAND, 0)

        draw_svbox.Add(draw_vbox, 1, wx.EXPAND, 5)

        main_vbox.Add(draw_svbox, 1, wx.BOTTOM | wx.EXPAND | wx.LEFT |
                      wx.RIGHT, 10)

        self.SetSizer(main_vbox)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.mode_rb.Bind(wx.EVT_RADIOBOX, self.mode_rbOnRadioBox)
        self.quad_ckb.Bind(wx.EVT_CHECKBOX, self.quad_ckbOnCheckBox)
        self.bend_ckb.Bind(wx.EVT_CHECKBOX, self.bend_ckbOnCheckBox)
        self.rf_ckb.Bind(wx.EVT_CHECKBOX, self.rf_ckbOnCheckBox)
        self.monitor_ckb.Bind(wx.EVT_CHECKBOX, self.monitor_ckbOnCheckBox)
        self.undulator_ckb.Bind(wx.EVT_CHECKBOX, self.undulator_ckbOnCheckBox)
Пример #2
0
 def createFormatRadioBox(self):
     self.__radioBox = wx.RadioBox(self,
                                   label="导出格式",
                                   choices=self.__params.get("choices", []),
                                   style=wx.RA_SPECIFY_COLS)
     pass
Пример #3
0
    def browseDir(self, event):
        """
        Show the DirDialog and ask the user to change the directory where machine labels are stored
        """
        from skimage import io
        dlg = wx.DirDialog(
            self,
            "Choose the directory where your extracted frames are saved:",
            os.path.join(os.getcwd(), 'labeled-data'),
            style=wx.DD_DEFAULT_STYLE)
        if dlg.ShowModal() == wx.ID_OK:
            self.dir = dlg.GetPath()
            self.Button1.Enable(False)
            self.Button2.Enable(True)
            self.Button5.Enable(True)
        else:
            dlg.Destroy()
            self.Close(True)
        dlg.Destroy()
        with open(str(self.config_file), 'r') as ymlfile:
            self.cfg = yaml.load(ymlfile)
        self.scorer = self.cfg['scorer']
        self.bodyparts = self.cfg['bodyparts']
        self.videos = self.cfg['video_sets'].keys()
        self.markerSize = self.cfg['dotsize']
        self.colormap = plt.get_cmap(self.cfg['colormap'])
        self.project_path = self.cfg['project_path']
        self.index = glob.glob(os.path.join(self.dir, '*.png'))
        self.index.sort(
        )  #sort the files thx to Robert Eppley for this suggestion
        print('Working on folder: {}'.format(os.path.split(str(self.dir))[-1]))

        #self.relativeimagenames=self.index ##[n.split(self.project_path+'/')[1] for n in self.index]
        #self.relativeimagenames=[n.split(self.project_path+'/')[1] for n in self.index]
        self.relativeimagenames = [
            'labeled' + n.split('labeled')[1] for n in self.index
        ]

        self.fig1, (self.ax1f1) = plt.subplots(figsize=self.img_size,
                                               facecolor="None")
        self.iter = 0
        self.buttonCounter = []
        im = io.imread(self.index[self.iter])

        im_axis = self.ax1f1.imshow(im, self.colormap)

        img_name = Path(
            self.index[self.iter]).name  # self.index[self.iter].split('/')[-1]
        self.ax1f1.set_title(
            str(
                str(self.iter + 1) + "/" + str(len(self.index)) + " " +
                img_name))
        self.canvas = FigureCanvasWxAgg(self, -1, self.fig1)
        self.toolbar = NavigationToolbar(self.canvas)

        #checks for unique bodyparts
        if len(self.bodyparts) != len(set(self.bodyparts)):
            print(
                "Error! bodyparts must have unique labels! Please choose unique bodyparts in config.yaml file and try again. Quiting for now!"
            )
            self.Destroy()

        if self.new_labels == True:
            self.oldDF = pd.read_hdf(
                os.path.join(self.dir, 'CollectedData_' + self.scorer + '.h5'),
                'df_with_missing')
            oldBodyParts = self.oldDF.columns.get_level_values(1)
            _, idx = np.unique(oldBodyParts, return_index=True)
            oldbodyparts2plot = list(oldBodyParts[np.sort(idx)])
            self.bodyparts = list(set(self.bodyparts) - set(oldbodyparts2plot))
            self.rdb = wx.RadioBox(self,
                                   id=1,
                                   label="Select a body part to annotate",
                                   pos=(self.gui_width * .83,
                                        self.gui_height * .1),
                                   choices=self.bodyparts,
                                   majorDimension=1,
                                   style=wx.RA_SPECIFY_COLS,
                                   validator=wx.DefaultValidator,
                                   name=wx.RadioBoxNameStr)
            self.option = self.rdb.Bind(wx.EVT_RADIOBOX, self.onRDB)
            cbar = self.fig1.colorbar(im_axis, ax=self.ax1f1)
            cbar.set_ticks(
                range(12, np.max(im),
                      int(np.floor(np.max(im) / len(self.bodyparts) - 1))))
            cbar.set_ticklabels(self.bodyparts)
        else:
            self.addLabel.Enable(False)
            cbar = self.fig1.colorbar(im_axis, ax=self.ax1f1)
            cbar.set_ticks(
                range(12, np.max(im),
                      int(np.floor(np.max(im) / len(self.bodyparts) - 1))))
            cbar.set_ticklabels(self.bodyparts)
            self.rdb = wx.RadioBox(self,
                                   id=1,
                                   label="Select a body part to annotate",
                                   pos=(self.gui_width * .83,
                                        self.gui_height * .1),
                                   choices=self.bodyparts,
                                   majorDimension=1,
                                   style=wx.RA_SPECIFY_COLS,
                                   validator=wx.DefaultValidator,
                                   name=wx.RadioBoxNameStr)
            self.option = self.rdb.Bind(wx.EVT_RADIOBOX, self.onRDB)

        self.cidClick = self.canvas.mpl_connect('button_press_event',
                                                self.onClick)
        self.flag = 0
        self.num = []
        self.counter = []
        self.presentCoords = []

        self.colorparams = list(range(0, len(self.bodyparts) + 1))

        a = np.empty((
            len(self.index),
            2,
        ))
        a[:] = np.nan
        for bodypart in self.bodyparts:
            index = pd.MultiIndex.from_product(
                [[self.scorer], [bodypart], ['x', 'y']],
                names=['scorer', 'bodyparts', 'coords'])
            #frame = pd.DataFrame(a, columns = index, index = self.index)
            frame = pd.DataFrame(a,
                                 columns=index,
                                 index=self.relativeimagenames)
            self.dataFrame = pd.concat([self.dataFrame, frame], axis=1)

        if self.file == 0:
            self.checkBox = wx.CheckBox(self,
                                        label='Adjust marker size.',
                                        pos=(self.gui_width * .43,
                                             self.gui_height * .85))
            self.checkBox.Bind(wx.EVT_CHECKBOX, self.onChecked)
            self.slider = wx.Slider(
                self,
                -1,
                18,
                0,
                20,
                size=(200, -1),
                pos=(self.gui_width * .40, self.gui_height * .78),
                style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
            self.slider.Bind(wx.EVT_SLIDER, self.OnSliderScroll)
            self.slider.Enable(True)
Пример #4
0
 def __init__(self,
              parent,
              node_ids,
              tree,
              title,
              allow_tot,
              measures,
              sort_opt_allowed,
              rets_dic,
              horizontal=True,
              show_select_toggle=False):
     """
     Collects configuration details for rows and cols.
     node_ids -- list, even if only one item selected.
     """
     wx.Dialog.__init__(self, parent, id=-1, title=title)
     self.node_ids = node_ids
     first_node_id = node_ids[0]
     self.tree = tree
     self.allow_tot = allow_tot
     self.measures = measures
     self.sort_opt_allowed = sort_opt_allowed
     self.rets_dic = rets_dic
     ## base item configuration on first one selected
     item_conf = self.tree.GetItemPyData(first_node_id)
     chk_size = (170, 20)
     szr_main = wx.BoxSizer(wx.VERTICAL)
     var_lbl = tree.GetItemText(first_node_id)
     lbl_var = wx.StaticText(self, -1, var_lbl)
     szr_main.Add(lbl_var, 0, wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT, 10)
     if self.allow_tot:
         box_misc = wx.StaticBox(self, -1, _("Misc"))
         szr_misc = wx.StaticBoxSizer(box_misc, wx.VERTICAL)
         self.chk_total = wx.CheckBox(self, -1, mg.HAS_TOTAL, size=chk_size)
         if item_conf.has_tot:
             self.chk_total.SetValue(True)
         szr_misc.Add(self.chk_total, 0, wx.LEFT, 5)
         szr_main.Add(szr_misc, 0, wx.GROW | wx.ALL, 10)
     if self.sort_opt_allowed != mg.SORT_NO_OPTS:
         self.rad_sort_opts = wx.RadioBox(self,
                                          -1,
                                          _("Sort order"),
                                          choices=self.sort_opt_allowed,
                                          size=(-1, 50))
         ## set selection according to existing item_conf
         try:
             idx_sort_opt = self.sort_opt_allowed.index(
                 item_conf.sort_order)
             self.rad_sort_opts.SetSelection(idx_sort_opt)
         except IndexError:
             pass
         szr_main.Add(self.rad_sort_opts, 0, wx.GROW | wx.LEFT | wx.RIGHT,
                      10)
     self.measure_chks_dic = {}
     if self.measures:
         bx_measures = wx.StaticBox(self, -1, _("Measures"))
         direction = wx.HORIZONTAL if horizontal else wx.VERTICAL
         szr_measures = wx.StaticBoxSizer(bx_measures, direction)
         for measure_lbl in self.measures:
             label = mg.MEASURE_LBLS_SHORT2LONG[measure_lbl]
             chk = wx.CheckBox(self, -1, label, size=chk_size)
             if measure_lbl in item_conf.measures_lst:
                 chk.SetValue(True)
             self.measure_chks_dic[measure_lbl] = chk
             szr_measures.Add(chk, 1, wx.ALL, 5)
         if show_select_toggle:
             self.btn_select_toggle = wx.Button(self, -1, mg.SELECT_ALL_LBL)
             self.btn_select_toggle.Bind(wx.EVT_BUTTON,
                                         self.on_btn_select_toggle)
             szr_measures.Insert(0, self.btn_select_toggle, 0, wx.TOP, 5)
             self.button2showall = self._any_unticked()
             self._set_btn_lbl()
         szr_main.Add(szr_measures, 1, wx.GROW | wx.ALL, 10)
     btn_cancel = wx.Button(self, wx.ID_CANCEL)
     btn_cancel.Bind(wx.EVT_BUTTON, self.on_cancel)
     btn_ok = wx.Button(self, wx.ID_OK)  ## must have ID of wx.ID_OK
     ## to trigger validators (no event binding needed) and
     ## for std dialog button layout
     btn_ok.Bind(wx.EVT_BUTTON, self.on_ok)
     btn_ok.SetDefault()
     ## using the approach which will follow the platform convention
     ## for standard buttons
     szr_btns = wx.StdDialogButtonSizer()
     szr_btns.Add(40, 5, 0)  ## ensure wide enough for title
     szr_btns.AddButton(btn_cancel)
     szr_btns.AddButton(btn_ok)
     szr_btns.Realize()
     szr_main.Add(szr_btns, 0, wx.GROW | wx.ALL, 10)
     szr_main.SetSizeHints(self)
     self.SetSizer(szr_main)
     self.Fit()
Пример #5
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)

        self.log = log

        self.label1 = "Click here to show pane"
        self.label2 = "Click here to hide pane"

        title = wx.StaticText(self, label="PyCollapsiblePane")
        title.SetFont(
            wx.Font(18, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))
        title.SetForegroundColour("blue")

        self.cpStyle = wx.CP_NO_TLW_RESIZE
        self.cp = cp = PCP.PyCollapsiblePane(self,
                                             label=self.label1,
                                             agwStyle=self.cpStyle)
        self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, cp)
        self.MakePaneContent(cp.GetPane())

        self.btnRB = radioBox = wx.RadioBox(self,
                                            -1,
                                            "Button Types",
                                            choices=choices,
                                            style=wx.RA_SPECIFY_ROWS)
        self.static1 = wx.StaticText(self, -1, "Collapsed Button Text:")
        self.static2 = wx.StaticText(self, -1, "Expanded Button Text:")

        self.buttonText1 = wx.TextCtrl(self, -1, self.label1)
        self.buttonText2 = wx.TextCtrl(self, -1, self.label2)
        self.updateButton = wx.Button(self, -1, "Update!")

        sbox = wx.StaticBox(self, -1, 'Styles')
        sboxsizer = wx.StaticBoxSizer(sbox, wx.VERTICAL)
        self.styleCBs = list()
        for styleName in styles:
            cb = wx.CheckBox(self, -1, styleName)
            if styleName == "CP_NO_TLW_RESIZE":
                cb.SetValue(True)
                cb.Disable()
            cb.Bind(wx.EVT_CHECKBOX, self.OnStyleChoice)
            self.styleCBs.append(cb)
            sboxsizer.Add(cb, 0, wx.ALL, 4)

        self.gtkText = wx.StaticText(self, -1, "Expander Size")
        self.gtkChoice = wx.ComboBox(self, -1, choices=gtkChoices)
        self.gtkChoice.SetSelection(0)

        self.gtkText.Enable(False)
        self.gtkChoice.Enable(False)

        sizer = wx.BoxSizer(wx.VERTICAL)
        radioSizer = wx.BoxSizer(wx.HORIZONTAL)
        dummySizer = wx.BoxSizer(wx.VERTICAL)

        dummySizer.Add(self.gtkText, 0, wx.EXPAND | wx.BOTTOM, 2)
        dummySizer.Add(self.gtkChoice, 0, wx.EXPAND)

        radioSizer.Add(radioBox, 0, wx.EXPAND)
        radioSizer.Add(sboxsizer, 0, wx.EXPAND | wx.LEFT, 10)
        radioSizer.Add(dummySizer, 0, wx.ALIGN_BOTTOM | wx.LEFT, 10)

        self.SetSizer(sizer)
        sizer.Add((0, 10))
        sizer.Add(title, 0, wx.LEFT | wx.RIGHT, 25)
        sizer.Add((0, 10))
        sizer.Add(radioSizer, 0, wx.LEFT, 25)

        sizer.Add((0, 10))
        subSizer = wx.FlexGridSizer(2, 3, 5, 5)
        subSizer.Add(self.static1, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
        subSizer.Add(self.buttonText1, 0, wx.EXPAND)
        subSizer.Add((0, 0))
        subSizer.Add(self.static2, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
        subSizer.Add(self.buttonText2, 0, wx.EXPAND)
        subSizer.Add(self.updateButton, 0, wx.LEFT | wx.RIGHT, 10)

        subSizer.AddGrowableCol(1)

        sizer.Add(subSizer, 0, wx.EXPAND | wx.LEFT, 20)
        sizer.Add((0, 15))
        sizer.Add(cp, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 20)

        self.btn = wx.Button(self, label=btnlbl1)
        sizer.Add(self.btn, 0, wx.ALL, 25)

        self.Bind(wx.EVT_BUTTON, self.OnToggle, self.btn)
        self.Bind(wx.EVT_BUTTON, self.OnUpdate, self.updateButton)
        self.Bind(wx.EVT_RADIOBOX, self.OnButtonChoice)
        self.Bind(wx.EVT_COMBOBOX, self.OnUserChoice, self.gtkChoice)
Пример #6
0
    def InitUI(self):
        self.CreateStatusBar()

        panel = wx.Panel(self)
        sizer = wx.GridBagSizer(5, 5)

        st1 = wx.StaticText(panel, label="Username:"******"REDDIT_USERNAME"]
        self.uname.SetValue(username)
        sizer.Add(self.uname,
                  pos=(0, 1),
                  flag=wx.ALL | wx.ALIGN_LEFT,
                  border=5)

        st2 = wx.StaticText(panel, label="Password:"******"REDDIT_PASSWORD"]
        self.pword.SetValue(password)
        sizer.Add(self.pword,
                  pos=(0, 3),
                  flag=wx.ALL | wx.ALIGN_LEFT,
                  border=5)

        btn1 = wx.Button(panel, label="Update")
        sizer.Add(btn1, pos=(1, 4), flag=wx.ALL, border=5)

        self.comments = wx.CheckBox(panel, label="Wipe comments")
        sizer.Add(self.comments,
                  pos=(1, 2),
                  flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                  border=5)

        self.submissions = wx.CheckBox(panel, label="Wipe submissions")
        sizer.Add(
            self.submissions,
            pos=(1, 1),
            flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
            border=5,
        )

        self.verbose = wx.CheckBox(panel, label="Verbose output")
        self.verbose.SetValue(True)
        sizer.Add(self.verbose,
                  pos=(1, 3),
                  flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                  border=5)

        btn2 = wx.Button(panel, label="Wipe")
        sizer.Add(btn2,
                  pos=(2, 4),
                  flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                  border=5)

        self.rbox = wx.RadioBox(
            panel,
            label="Age for deletion",
            style=wx.RA_SPECIFY_ROWS,
            choices=("Any age", "Older than X minutes"),
            majorDimension=1,
        )
        sizer.Add(self.rbox, pos=(2, 0), span=(0, 3), flag=wx.ALL, border=5)

        self.age = wx.SpinCtrl(
            panel,
            value="0",
            max=99999999,
            name="Min age to delete",
            style=wx.ALIGN_RIGHT,
        )
        sizer.Add(self.age, pos=(2, 3), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL)

        legendtext = "".join(
            "1 day = {:,} minutes, 1 month = {:,} minutes, 1 year = {:,} minutes"
            .format(60 * 24, 60 * 24 * 30, 60 * 24 * 365))
        legend = wx.StaticText(panel, label=legendtext)
        sizer.Add(
            legend,
            pos=(3, 0),
            span=(0, 5),
            flag=wx.ALL | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL,
            border=5,
        )

        self.found = wx.TextCtrl(panel)
        sizer.Add(
            self.found,
            pos=(4, 0),
            span=(0, 5),
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TE_READONLY,
            border=5,
        )

        self.tc2 = wx.TextCtrl(panel, style=wx.TE_MULTILINE | wx.TE_READONLY)
        sizer.Add(
            self.tc2,
            pos=(5, 0),
            span=(0, 5),
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
            border=5,
        )

        sizer.AddGrowableRow(5)

        panel.SetSizer(sizer)

        self.Bind(wx.EVT_BUTTON, self.Login, id=btn1.GetId())
        self.Bind(wx.EVT_BUTTON, self.Process, id=btn2.GetId())
        self.Bind(wx.EVT_SPINCTRL, self.UpdateAge)
        self.loggedin = False
Пример #7
0
    def create_gui(self):
        self.SetTitle("Menu Editor")

        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_2 = wx.FlexGridSizer(5, 2, 0, 0)

        # menu item fields
        self.label_6 = wx.StaticText(self, wx.ID_ANY, "Label:")
        grid_sizer_2.Add(self.label_6, 0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.label = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer_2.Add(self.label, 1, wx.EXPAND, 0)

        self.label_7 = wx.StaticText(self, wx.ID_ANY, "Event Handler:")
        grid_sizer_2.Add(self.label_7, 0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.event_handler = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer_2.Add(self.event_handler, 1, wx.EXPAND, 0)

        self.label_8 = wx.StaticText(self, wx.ID_ANY, "(Attribute) Name:")
        grid_sizer_2.Add(self.label_8, 0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.name = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer_2.Add(self.name, 1, wx.EXPAND, 0)

        self.label_9 = wx.StaticText(self, wx.ID_ANY, "Help String:")
        grid_sizer_2.Add(self.label_9, 0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.help_str = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer_2.Add(self.help_str, 1, wx.EXPAND, 0)

        self.label_10 = wx.StaticText(self, wx.ID_ANY, "ID:")
        grid_sizer_2.Add(self.label_10, 0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.id = wx.TextCtrl(self, wx.ID_ANY, "")
        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        hsizer.Add(self.id, 1)
        hsizer.Add((4, 4), 1)
        grid_sizer_2.Add(hsizer, 1, wx.EXPAND, 0)

        grid_sizer_2.AddGrowableCol(1)
        sizer_5.Add(grid_sizer_2, 2, wx.EXPAND, 0)

        # radio box for type
        self.type = wx.RadioBox(self,
                                wx.ID_ANY,
                                "Type",
                                choices=["Normal", "Checkable", "Radio"],
                                majorDimension=1,
                                style=wx.RA_SPECIFY_COLS)
        self.type.SetSelection(0)
        sizer_5.Add(self.type, 0, wx.ALL | wx.EXPAND, 4)

        sizer_5.Add((20, 20), 1, 0, 0)

        # editor action buttons
        self.move_left = wx.Button(self, wx.ID_ANY, "&<")
        self.move_right = wx.Button(self, wx.ID_ANY, "&>")
        self.move_up = wx.Button(self, wx.ID_ANY, "&Up")
        self.move_down = wx.Button(self, wx.ID_ANY, "&Down")
        self.add = wx.Button(self, wx.ID_ANY, "&Add")
        self.remove = wx.Button(self, wx.ID_ANY, "&Remove")
        self.add_sep = wx.Button(self, wx.ID_ANY, "Add &Separator")

        # dialog action buttons; these will be handled, instead of using stock OK/Cancel buttons
        self.ok = wx.Button(self, wx.ID_ANY, "OK")
        self.cancel = wx.Button(self, wx.ID_ANY, "Cancel")

        sizer_6.Add(self.ok, 0, wx.ALL, 5)
        sizer_6.Add(self.cancel, 0, wx.ALL, 5)
        sizer_5.Add(sizer_6, 0, wx.EXPAND, 0)
        sizer_1.Add(sizer_5, 0, wx.EXPAND, 0)
        sizer_2.Add(self.move_left, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 8)
        sizer_2.Add(self.move_right, 0, wx.BOTTOM | wx.RIGHT | wx.TOP, 8)
        sizer_2.Add(self.move_up, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 8)
        sizer_2.Add(self.move_down, 0, wx.BOTTOM | wx.RIGHT | wx.TOP, 8)
        sizer_2.Add((20, 20), 1, 0, 0)
        sizer_2.Add(self.add, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 8)
        sizer_2.Add(self.remove, 0, wx.BOTTOM | wx.TOP, 8)
        sizer_2.Add(self.add_sep, 0, wx.ALL, 8)
        sizer_2.Add((20, 20), 2, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)

        self.items = wx.ListCtrl(
            self,
            wx.ID_ANY,
            style=wx.BORDER_DEFAULT | wx.BORDER_SUNKEN | wx.LC_EDIT_LABELS
            | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.NO_FULL_REPAINT_ON_RESIZE)
        sizer_1.Add(self.items, 1, wx.EXPAND, 0)

        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        sizer_1.SetSizeHints(self)
        self.Layout()

        self.SetSize((900, 600))
Пример #8
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: All_Widgets_Frame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((800, 417))
        self.SetTitle(_("All Widgets"))
        _icon = wx.NullIcon
        _icon.CopyFromBitmap(wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (32, 32)))
        self.SetIcon(_icon)

        # Menu Bar
        self.All_Widgets_menubar = wx.MenuBar()
        global mn_IDUnix; mn_IDUnix = wx.NewId()
        global mn_IDWindows; mn_IDWindows = wx.NewId()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_OPEN, _("&Open"), _("Open an existing document"))
        wxglade_tmp_menu.Append(wx.ID_CLOSE, _("&Close file"), _("Close current document"))
        wxglade_tmp_menu.AppendSeparator()
        wxglade_tmp_menu.Append(wx.ID_EXIT, _("E&xit"), _("Finish program"))
        self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&File"))
        wxglade_tmp_menu = wx.Menu()
        self.All_Widgets_menubar.mn_Unix = wxglade_tmp_menu.Append(mn_IDUnix, _("Unix"), _("Use Unix line endings"), wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onSelectUnix, id=mn_IDUnix)
        self.All_Widgets_menubar.mn_Windows = wxglade_tmp_menu.Append(mn_IDWindows, _("Windows"), _("Use Windows line endings"), wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onSelectWindows, id=mn_IDWindows)
        wxglade_tmp_menu.AppendSeparator()
        self.All_Widgets_menubar.mn_RemoveTabs = wxglade_tmp_menu.Append(wx.ID_ANY, _("Remove Tabs"), _("Remove all leading tabs"), wx.ITEM_CHECK)
        self.Bind(wx.EVT_MENU, self.onRemoveTabs, self.All_Widgets_menubar.mn_RemoveTabs)
        self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&Edit"))
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_HELP, _("Manual"), _("Show the application manual"))
        self.Bind(wx.EVT_MENU, self.onShowManual, id=wx.ID_HELP)
        wxglade_tmp_menu.AppendSeparator()
        wxglade_tmp_menu.Append(wx.ID_ABOUT, _("About"), _("Show the About dialog"))
        self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&Help"))
        self.SetMenuBar(self.All_Widgets_menubar)
        # Menu Bar end

        self.All_Widgets_statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP)
        self.All_Widgets_statusbar.SetStatusWidths([-1])
        # statusbar fields
        All_Widgets_statusbar_fields = [_("All Widgets statusbar")]
        for i in range(len(All_Widgets_statusbar_fields)):
            self.All_Widgets_statusbar.SetStatusText(All_Widgets_statusbar_fields[i], i)

        # Tool Bar
        self.All_Widgets_toolbar = wx.ToolBar(self, -1)
        self.All_Widgets_toolbar.AddTool(wx.ID_UP, _("UpDown"), wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (32, 32)), wx.ArtProvider.GetBitmap(wx.ART_GO_DOWN, wx.ART_OTHER, (32, 32)), wx.ITEM_CHECK, _("Up or Down"), _("Up or Down"))
        self.All_Widgets_toolbar.AddTool(wx.ID_OPEN, _("Open"), wx.Bitmap(32, 32), wx.NullBitmap, wx.ITEM_NORMAL, _("Open a new file"), _("Open a new file"))
        self.SetToolBar(self.All_Widgets_toolbar)
        self.All_Widgets_toolbar.Realize()
        # Tool Bar end

        sizer_1 = wx.FlexGridSizer(3, 1, 0, 0)

        self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=wx.NB_BOTTOM)
        sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)

        self.notebook_1_wxBitmapButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxBitmapButton, _("wxBitmapButton"))

        sizer_13 = wx.FlexGridSizer(2, 2, 0, 0)

        self.bitmap_button_icon1 = wx.BitmapButton(self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY))
        self.bitmap_button_icon1.SetSize(self.bitmap_button_icon1.GetBestSize())
        self.bitmap_button_icon1.SetDefault()
        sizer_13.Add(self.bitmap_button_icon1, 1, wx.ALL | wx.EXPAND, 5)

        self.bitmap_button_empty1 = wx.BitmapButton(self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.Bitmap(10, 10))
        self.bitmap_button_empty1.SetSize(self.bitmap_button_empty1.GetBestSize())
        self.bitmap_button_empty1.SetDefault()
        sizer_13.Add(self.bitmap_button_empty1, 1, wx.ALL | wx.EXPAND, 5)

        self.bitmap_button_icon2 = wx.BitmapButton(self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY), style=wx.BORDER_NONE | wx.BU_BOTTOM)
        self.bitmap_button_icon2.SetBitmapDisabled(wx.Bitmap(32, 32))
        self.bitmap_button_icon2.SetSize(self.bitmap_button_icon2.GetBestSize())
        self.bitmap_button_icon2.SetDefault()
        sizer_13.Add(self.bitmap_button_icon2, 1, wx.ALL | wx.EXPAND, 5)

        self.bitmap_button_art = wx.BitmapButton(self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (32, 32)), style=wx.BORDER_NONE | wx.BU_BOTTOM)
        self.bitmap_button_art.SetSize(self.bitmap_button_art.GetBestSize())
        self.bitmap_button_art.SetDefault()
        sizer_13.Add(self.bitmap_button_art, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxButton, _("wxButton"))

        sizer_28 = wx.BoxSizer(wx.HORIZONTAL)

        self.button_3 = wx.Button(self.notebook_1_wxButton, wx.ID_BOLD, "")
        sizer_28.Add(self.button_3, 0, wx.ALL, 5)

        self.notebook_1_wxCalendarCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxCalendarCtrl, _("wxCalendarCtrl"))

        sizer_12 = wx.BoxSizer(wx.HORIZONTAL)

        self.calendar_ctrl_1 = wx.adv.CalendarCtrl(self.notebook_1_wxCalendarCtrl, wx.ID_ANY, style=wx.adv.CAL_MONDAY_FIRST | wx.adv.CAL_SEQUENTIAL_MONTH_SELECTION | wx.adv.CAL_SHOW_SURROUNDING_WEEKS)
        sizer_12.Add(self.calendar_ctrl_1, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxCheckBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxCheckBox, _("wxCheckBox"))

        sizer_21 = wx.GridSizer(2, 3, 0, 0)

        self.checkbox_1 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("one (unchecked)"))
        sizer_21.Add(self.checkbox_1, 0, wx.EXPAND, 0)

        self.checkbox_2 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("two (checked)"))
        self.checkbox_2.SetValue(1)
        sizer_21.Add(self.checkbox_2, 0, wx.EXPAND, 0)

        self.checkbox_3 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("three"), style=wx.CHK_2STATE)
        sizer_21.Add(self.checkbox_3, 0, wx.EXPAND, 0)

        self.checkbox_4 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("four (unchecked)"), style=wx.CHK_3STATE)
        self.checkbox_4.Set3StateValue(wx.CHK_UNCHECKED)
        sizer_21.Add(self.checkbox_4, 0, wx.EXPAND, 0)

        self.checkbox_5 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("five (checked)"), style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.checkbox_5.Set3StateValue(wx.CHK_CHECKED)
        sizer_21.Add(self.checkbox_5, 0, wx.EXPAND, 0)

        self.checkbox_6 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("six (undetermined)"), style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.checkbox_6.Set3StateValue(wx.CHK_UNDETERMINED)
        sizer_21.Add(self.checkbox_6, 0, wx.EXPAND, 0)

        self.notebook_1_wxCheckListBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxCheckListBox, _("wxCheckListBox"))

        sizer_26 = wx.BoxSizer(wx.HORIZONTAL)

        self.check_list_box_1 = wx.CheckListBox(self.notebook_1_wxCheckListBox, wx.ID_ANY, choices=[_("one"), _("two"), _("three"), _("four")])
        self.check_list_box_1.SetSelection(2)
        sizer_26.Add(self.check_list_box_1, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxChoice = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxChoice, _("wxChoice"))

        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)

        self.choice_empty = wx.Choice(self.notebook_1_wxChoice, wx.ID_ANY, choices=[])
        sizer_5.Add(self.choice_empty, 1, wx.ALL, 5)

        self.choice_filled = wx.Choice(self.notebook_1_wxChoice, wx.ID_ANY, choices=[_("Item 1"), _("Item 2 (pre-selected)")])
        self.choice_filled.SetSelection(1)
        sizer_5.Add(self.choice_filled, 1, wx.ALL, 5)

        self.notebook_1_wxComboBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxComboBox, _("wxComboBox"))

        sizer_6 = wx.BoxSizer(wx.VERTICAL)

        sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6.Add(sizer_7, 1, wx.EXPAND, 0)

        self.combo_box_empty = wx.ComboBox(self.notebook_1_wxComboBox, wx.ID_ANY, choices=[], style=0)
        sizer_7.Add(self.combo_box_empty, 1, wx.ALL, 5)

        self.combo_box_filled = wx.ComboBox(self.notebook_1_wxComboBox, wx.ID_ANY, choices=[_("Item 1 (pre-selected)"), _("Item 2")], style=0)
        self.combo_box_filled.SetSelection(0)
        sizer_7.Add(self.combo_box_filled, 1, wx.ALL, 5)

        self.notebook_1_wxDatePickerCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxDatePickerCtrl, _("wxDatePickerCtrl"))

        sizer_17 = wx.BoxSizer(wx.HORIZONTAL)

        self.datepicker_ctrl_1 = wx.adv.DatePickerCtrl(self.notebook_1_wxDatePickerCtrl, wx.ID_ANY, style=wx.adv.DP_SHOWCENTURY)
        sizer_17.Add(self.datepicker_ctrl_1, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.notebook_1_wxGauge = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxGauge, _("wxGauge"))

        sizer_15 = wx.BoxSizer(wx.HORIZONTAL)

        self.gauge_1 = wx.Gauge(self.notebook_1_wxGauge, wx.ID_ANY, 20)
        sizer_15.Add(self.gauge_1, 1, wx.ALL, 5)

        self.notebook_1_wxGrid = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxGrid, _("wxGrid"))

        sizer_19 = wx.BoxSizer(wx.HORIZONTAL)

        self.grid_1 = wx.grid.Grid(self.notebook_1_wxGrid, wx.ID_ANY, size=(1, 1))
        self.grid_1.CreateGrid(10, 3)
        self.grid_1.SetSelectionMode(wx.grid.Grid.SelectRows)
        sizer_19.Add(self.grid_1, 1, wx.EXPAND, 0)

        self.notebook_1_wxHyperlinkCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxHyperlinkCtrl, _("wxHyperlinkCtrl"))

        sizer_20 = wx.BoxSizer(wx.HORIZONTAL)

        self.hyperlink_1 = wx.adv.HyperlinkCtrl(self.notebook_1_wxHyperlinkCtrl, wx.ID_ANY, _("Homepage wxGlade"), _("http://wxglade.sf.net"))
        sizer_20.Add(self.hyperlink_1, 0, wx.ALL, 5)

        self.notebook_1_wxListBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxListBox, _("wxListBox"))

        sizer_4 = wx.BoxSizer(wx.VERTICAL)

        self.list_box_empty = wx.ListBox(self.notebook_1_wxListBox, wx.ID_ANY, choices=[], style=0)
        sizer_4.Add(self.list_box_empty, 1, wx.ALL | wx.EXPAND, 5)

        self.list_box_filled = wx.ListBox(self.notebook_1_wxListBox, wx.ID_ANY, choices=[_("Item 1"), _("Item 2 (pre-selected)")], style=wx.LB_MULTIPLE | wx.LB_SORT)
        self.list_box_filled.SetSelection(1)
        sizer_4.Add(self.list_box_filled, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxListCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxListCtrl, _("wxListCtrl"))

        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)

        self.list_ctrl_1 = wx.ListCtrl(self.notebook_1_wxListCtrl, wx.ID_ANY, style=wx.BORDER_SUNKEN | wx.LC_REPORT)
        sizer_3.Add(self.list_ctrl_1, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxRadioBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxRadioBox, _("wxRadioBox"))

        grid_sizer_1 = wx.GridSizer(2, 2, 0, 0)

        self.radio_box_empty1 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_empty1"), choices=[""], majorDimension=1, style=wx.RA_SPECIFY_ROWS)
        grid_sizer_1.Add(self.radio_box_empty1, 1, wx.ALL | wx.EXPAND, 5)

        self.radio_box_filled1 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_filled1"), choices=[_("choice 1"), _("choice 2 (pre-selected)"), _("choice 3")], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.radio_box_filled1.SetSelection(1)
        grid_sizer_1.Add(self.radio_box_filled1, 1, wx.ALL | wx.EXPAND, 5)

        self.radio_box_empty2 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_empty2"), choices=[""], majorDimension=1, style=wx.RA_SPECIFY_COLS)
        grid_sizer_1.Add(self.radio_box_empty2, 1, wx.ALL | wx.EXPAND, 5)

        self.radio_box_filled2 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_filled2"), choices=[_("choice 1"), _("choice 2 (pre-selected)")], majorDimension=0, style=wx.RA_SPECIFY_COLS)
        self.radio_box_filled2.SetSelection(1)
        grid_sizer_1.Add(self.radio_box_filled2, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxRadioButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxRadioButton, _("wxRadioButton"))

        sizer_8 = wx.StaticBoxSizer(wx.StaticBox(self.notebook_1_wxRadioButton, wx.ID_ANY, _("My RadioButton Group")), wx.HORIZONTAL)

        grid_sizer_2 = wx.FlexGridSizer(3, 2, 0, 0)
        sizer_8.Add(grid_sizer_2, 1, wx.EXPAND, 0)

        self.radio_btn_1 = wx.RadioButton(self.notebook_1_wxRadioButton, wx.ID_ANY, _("Alice"), style=wx.RB_GROUP)
        grid_sizer_2.Add(self.radio_btn_1, 1, wx.ALL | wx.EXPAND, 5)

        self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_wxRadioButton, wx.ID_ANY, "")
        grid_sizer_2.Add(self.text_ctrl_1, 1, wx.ALL | wx.EXPAND, 5)

        self.radio_btn_2 = wx.RadioButton(self.notebook_1_wxRadioButton, wx.ID_ANY, _("Bob"))
        grid_sizer_2.Add(self.radio_btn_2, 1, wx.ALL | wx.EXPAND, 5)

        self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_wxRadioButton, wx.ID_ANY, "")
        grid_sizer_2.Add(self.text_ctrl_2, 1, wx.ALL | wx.EXPAND, 5)

        self.radio_btn_3 = wx.RadioButton(self.notebook_1_wxRadioButton, wx.ID_ANY, _("Malroy"))
        grid_sizer_2.Add(self.radio_btn_3, 1, wx.ALL | wx.EXPAND, 5)

        self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_wxRadioButton, wx.ID_ANY, "")
        grid_sizer_2.Add(self.text_ctrl_3, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxSlider = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxSlider, _("wxSlider"))

        sizer_22 = wx.BoxSizer(wx.HORIZONTAL)

        self.slider_1 = wx.Slider(self.notebook_1_wxSlider, wx.ID_ANY, 5, 0, 10, style=0)
        sizer_22.Add(self.slider_1, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxSpinButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxSpinButton, _("wxSpinButton (with wxTextCtrl)"))

        sizer_16 = wx.BoxSizer(wx.HORIZONTAL)

        self.tc_spin_button = wx.TextCtrl(self.notebook_1_wxSpinButton, wx.ID_ANY, _("1"), style=wx.TE_RIGHT)
        sizer_16.Add(self.tc_spin_button, 1, wx.ALL, 5)

        self.spin_button = wx.SpinButton(self.notebook_1_wxSpinButton, wx.ID_ANY )
        sizer_16.Add(self.spin_button, 1, wx.ALL, 5)

        self.notebook_1_wxSpinCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxSpinCtrl, _("wxSpinCtrl"))

        sizer_14 = wx.BoxSizer(wx.HORIZONTAL)

        self.spin_ctrl_1 = wx.SpinCtrl(self.notebook_1_wxSpinCtrl, wx.ID_ANY, "4", min=0, max=100)
        sizer_14.Add(self.spin_ctrl_1, 1, wx.ALL, 5)

        self.notebook_1_wxSplitterWindow_horizontal = wx.ScrolledWindow(self.notebook_1, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
        self.notebook_1_wxSplitterWindow_horizontal.SetScrollRate(10, 10)
        self.notebook_1.AddPage(self.notebook_1_wxSplitterWindow_horizontal, _("wxSplitterWindow (horizontally)"))

        sizer_29 = wx.BoxSizer(wx.HORIZONTAL)

        self.splitter_1 = wx.SplitterWindow(self.notebook_1_wxSplitterWindow_horizontal, wx.ID_ANY, style=0)
        self.splitter_1.SetMinimumPaneSize(20)
        sizer_29.Add(self.splitter_1, 1, wx.ALL | wx.EXPAND, 5)

        self.splitter_1_pane_1 = wx.Panel(self.splitter_1, wx.ID_ANY)

        sizer_30 = wx.BoxSizer(wx.HORIZONTAL)

        self.label_top_pane = wx.StaticText(self.splitter_1_pane_1, wx.ID_ANY, _("top pane"))
        sizer_30.Add(self.label_top_pane, 1, wx.ALL | wx.EXPAND, 5)

        self.splitter_1_pane_2 = wx.Panel(self.splitter_1, wx.ID_ANY)

        sizer_31 = wx.BoxSizer(wx.HORIZONTAL)

        self.label_buttom_pane = wx.StaticText(self.splitter_1_pane_2, wx.ID_ANY, _("bottom pane"))
        sizer_31.Add(self.label_buttom_pane, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxSplitterWindow_vertical = wx.ScrolledWindow(self.notebook_1, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
        self.notebook_1_wxSplitterWindow_vertical.SetScrollRate(10, 10)
        self.notebook_1.AddPage(self.notebook_1_wxSplitterWindow_vertical, _("wxSplitterWindow (vertically)"))

        sizer_25 = wx.BoxSizer(wx.HORIZONTAL)

        self.splitter_2 = wx.SplitterWindow(self.notebook_1_wxSplitterWindow_vertical, wx.ID_ANY, style=0)
        self.splitter_2.SetMinimumPaneSize(20)
        sizer_25.Add(self.splitter_2, 1, wx.ALL | wx.EXPAND, 5)

        self.splitter_2_pane_1 = wx.Panel(self.splitter_2, wx.ID_ANY)

        sizer_32 = wx.BoxSizer(wx.VERTICAL)

        self.label_left_pane = wx.StaticText(self.splitter_2_pane_1, wx.ID_ANY, _("left pane"))
        sizer_32.Add(self.label_left_pane, 1, wx.ALL | wx.EXPAND, 5)

        self.splitter_2_pane_2 = wx.Panel(self.splitter_2, wx.ID_ANY)

        sizer_33 = wx.BoxSizer(wx.VERTICAL)

        self.label_right_pane = wx.StaticText(self.splitter_2_pane_2, wx.ID_ANY, _("right pane"))
        sizer_33.Add(self.label_right_pane, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxStaticBitmap = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxStaticBitmap, _("wxStaticBitmap"))

        sizer_11 = wx.BoxSizer(wx.VERTICAL)

        self.bitmap_empty = wx.StaticBitmap(self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.Bitmap(32, 32))
        sizer_11.Add(self.bitmap_empty, 1, wx.ALL | wx.EXPAND, 5)

        self.bitmap_file = wx.StaticBitmap(self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY))
        sizer_11.Add(self.bitmap_file, 1, wx.ALL | wx.EXPAND, 5)

        self.bitmap_nofile = wx.StaticBitmap(self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.Bitmap("non-existing.bmp", wx.BITMAP_TYPE_ANY))
        sizer_11.Add(self.bitmap_nofile, 1, wx.ALL | wx.EXPAND, 5)

        self.bitmap_art = wx.StaticBitmap(self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, (32, 32)))
        sizer_11.Add(self.bitmap_art, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxStaticLine = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxStaticLine, _("wxStaticLine"))

        sizer_9 = wx.BoxSizer(wx.VERTICAL)

        sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_9.Add(sizer_10, 1, wx.EXPAND, 0)

        self.static_line_2 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY, style=wx.LI_VERTICAL)
        sizer_10.Add(self.static_line_2, 1, wx.ALL | wx.EXPAND, 5)

        self.static_line_3 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY, style=wx.LI_VERTICAL)
        sizer_10.Add(self.static_line_3, 1, wx.ALL | wx.EXPAND, 5)

        self.static_line_4 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY)
        sizer_9.Add(self.static_line_4, 1, wx.ALL | wx.EXPAND, 5)

        self.static_line_5 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY)
        sizer_9.Add(self.static_line_5, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxStaticText = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxStaticText, _("wxStaticText"))

        grid_sizer_3 = wx.FlexGridSizer(1, 3, 0, 0)

        self.label_1 = wx.StaticText(self.notebook_1_wxStaticText, wx.ID_ANY, _("red text (RGB)"), style=wx.ALIGN_CENTER_HORIZONTAL)
        self.label_1.SetForegroundColour(wx.Colour(255, 0, 0))
        grid_sizer_3.Add(self.label_1, 1, wx.ALL | wx.EXPAND, 5)

        self.label_4 = wx.StaticText(self.notebook_1_wxStaticText, wx.ID_ANY, _("black on red (RGB)"), style=wx.ALIGN_CENTER_HORIZONTAL)
        self.label_4.SetBackgroundColour(wx.Colour(255, 0, 0))
        self.label_4.SetToolTipString(_("Background colour won't show, check documentation for more details"))
        grid_sizer_3.Add(self.label_4, 1, wx.ALL | wx.EXPAND, 5)

        self.label_5 = wx.StaticText(self.notebook_1_wxStaticText, wx.ID_ANY, _("green on pink (RGB)"), style=wx.ALIGN_CENTER_HORIZONTAL)
        self.label_5.SetBackgroundColour(wx.Colour(255, 0, 255))
        self.label_5.SetForegroundColour(wx.Colour(0, 255, 0))
        self.label_5.SetToolTipString(_("Background colour won't show, check documentation for more details"))
        grid_sizer_3.Add(self.label_5, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_Spacer = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_Spacer, _("Spacer"))

        grid_sizer_4 = wx.FlexGridSizer(1, 3, 0, 0)

        self.label_3 = wx.StaticText(self.notebook_1_Spacer, wx.ID_ANY, _("Two labels with a"))
        grid_sizer_4.Add(self.label_3, 1, wx.ALL | wx.EXPAND, 5)

        grid_sizer_4.Add((60, 20), 1, wx.ALL | wx.EXPAND, 5)

        self.label_2 = wx.StaticText(self.notebook_1_Spacer, wx.ID_ANY, _("spacer between"))
        grid_sizer_4.Add(self.label_2, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxTextCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxTextCtrl, _("wxTextCtrl"))

        sizer_18 = wx.BoxSizer(wx.HORIZONTAL)

        self.text_ctrl = wx.TextCtrl(self.notebook_1_wxTextCtrl, wx.ID_ANY, _("This\nis\na\nmultiline\nwxTextCtrl"), style=wx.TE_CHARWRAP | wx.TE_MULTILINE | wx.TE_WORDWRAP)
        sizer_18.Add(self.text_ctrl, 1, wx.ALL | wx.EXPAND, 5)

        self.notebook_1_wxToggleButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxToggleButton, _("wxToggleButton"))

        sizer_23 = wx.BoxSizer(wx.HORIZONTAL)

        self.button_2 = wx.ToggleButton(self.notebook_1_wxToggleButton, wx.ID_ANY, _("Toggle Button 1"))
        sizer_23.Add(self.button_2, 1, wx.ALL, 5)

        self.button_4 = wx.ToggleButton(self.notebook_1_wxToggleButton, wx.ID_ANY, _("Toggle Button 2"), style=wx.BU_BOTTOM | wx.BU_EXACTFIT)
        sizer_23.Add(self.button_4, 1, wx.ALL, 5)

        self.notebook_1_wxTreeCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_wxTreeCtrl, _("wxTreeCtrl"))

        sizer_24 = wx.BoxSizer(wx.HORIZONTAL)

        self.tree_ctrl_1 = wx.TreeCtrl(self.notebook_1_wxTreeCtrl, wx.ID_ANY, style=0)
        sizer_24.Add(self.tree_ctrl_1, 1, wx.ALL | wx.EXPAND, 5)

        self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
        sizer_1.Add(self.static_line_1, 0, wx.ALL | wx.EXPAND, 5)

        sizer_2 = wx.FlexGridSizer(1, 2, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.ALIGN_RIGHT, 0)

        self.button_5 = wx.Button(self, wx.ID_CLOSE, "")
        sizer_2.Add(self.button_5, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP)
        sizer_2.Add(self.button_1, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.notebook_1_wxTreeCtrl.SetSizer(sizer_24)

        self.notebook_1_wxToggleButton.SetSizer(sizer_23)

        self.notebook_1_wxTextCtrl.SetSizer(sizer_18)

        self.notebook_1_Spacer.SetSizer(grid_sizer_4)

        self.notebook_1_wxStaticText.SetSizer(grid_sizer_3)

        self.notebook_1_wxStaticLine.SetSizer(sizer_9)

        self.notebook_1_wxStaticBitmap.SetSizer(sizer_11)

        self.splitter_2_pane_2.SetSizer(sizer_33)

        self.splitter_2_pane_1.SetSizer(sizer_32)

        self.splitter_2.SplitVertically(self.splitter_2_pane_1, self.splitter_2_pane_2)

        self.notebook_1_wxSplitterWindow_vertical.SetSizer(sizer_25)

        self.splitter_1_pane_2.SetSizer(sizer_31)

        self.splitter_1_pane_1.SetSizer(sizer_30)

        self.splitter_1.SplitHorizontally(self.splitter_1_pane_1, self.splitter_1_pane_2)

        self.notebook_1_wxSplitterWindow_horizontal.SetSizer(sizer_29)

        self.notebook_1_wxSpinCtrl.SetSizer(sizer_14)

        self.notebook_1_wxSpinButton.SetSizer(sizer_16)

        self.notebook_1_wxSlider.SetSizer(sizer_22)

        self.notebook_1_wxRadioButton.SetSizer(sizer_8)

        self.notebook_1_wxRadioBox.SetSizer(grid_sizer_1)

        self.notebook_1_wxListCtrl.SetSizer(sizer_3)

        self.notebook_1_wxListBox.SetSizer(sizer_4)

        self.notebook_1_wxHyperlinkCtrl.SetSizer(sizer_20)

        self.notebook_1_wxGrid.SetSizer(sizer_19)

        self.notebook_1_wxGauge.SetSizer(sizer_15)

        self.notebook_1_wxDatePickerCtrl.SetSizer(sizer_17)

        self.notebook_1_wxComboBox.SetSizer(sizer_6)

        self.notebook_1_wxChoice.SetSizer(sizer_5)

        self.notebook_1_wxCheckListBox.SetSizer(sizer_26)

        self.notebook_1_wxCheckBox.SetSizer(sizer_21)

        self.notebook_1_wxCalendarCtrl.SetSizer(sizer_12)

        self.notebook_1_wxButton.SetSizer(sizer_28)

        sizer_13.AddGrowableRow(0)
        sizer_13.AddGrowableRow(1)
        sizer_13.AddGrowableCol(0)
        sizer_13.AddGrowableCol(1)
        self.notebook_1_wxBitmapButton.SetSizer(sizer_13)

        sizer_1.AddGrowableRow(0)
        sizer_1.AddGrowableCol(0)
        self.SetSizer(sizer_1)
        sizer_1.SetSizeHints(self)

        self.Layout()
        self.Centre()

        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnNotebookPageChanged, self.notebook_1)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnNotebookPageChanging, self.notebook_1)
        self.Bind(wx.EVT_BUTTON, self.onStartConverting, self.button_1)
Пример #9
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 size=wx.DefaultSize,
                 style=0,
                 fps=25.0):
        super(FinishStripPanel, self).__init__(parent,
                                               id,
                                               size=size,
                                               style=style)

        self.fps = fps
        self.info = {}

        vs = wx.BoxSizer(wx.VERTICAL)

        displayWidth, displayHeight = wx.GetDisplaySize()

        self.leftToRight = True
        self.imageQuality = wx.IMAGE_QUALITY_NORMAL
        self.finish = FinishStrip(self,
                                  leftToRight=self.leftToRight,
                                  mouseWheelCallback=self.onMouseWheel,
                                  scrollCallback=self.scrollCallback)

        self.timeScrollbar = wx.ScrollBar(self, style=wx.SB_HORIZONTAL)
        self.timeScrollbar.Bind(wx.EVT_SCROLL, self.onChangeTime)

        minPixelsPerSecond, maxPixelsPerSecond = self.getSpeedPixelsPerSecondMinMax(
        )
        self.stretchSlider = wx.Slider(self,
                                       style=wx.SL_HORIZONTAL,
                                       minValue=minPixelsPerSecond,
                                       maxValue=maxPixelsPerSecond)
        self.stretchSlider.SetPageSize(1)
        self.stretchSlider.Bind(wx.EVT_SCROLL, self.onChangeSpeed)

        self.direction = wx.RadioBox(
            self,
            label=_('Finish Direction'),
            choices=[_('Right to Left'),
                     _('Left to Right')],
            majorDimension=1,
            style=wx.RA_SPECIFY_ROWS)
        self.direction.SetSelection(1 if self.leftToRight else 0)
        self.direction.Bind(wx.EVT_RADIOBOX, self.onDirection)

        self.imageQualitySelect = wx.RadioBox(
            self,
            label=_('Zoom Image Quality'),
            choices=[_('Normal (faster)'),
                     _('High (slower)')],
            majorDimension=1,
            style=wx.RA_SPECIFY_ROWS)
        self.imageQualitySelect.SetSelection(1 if self.imageQuality ==
                                             wx.IMAGE_QUALITY_HIGH else 0)
        self.imageQualitySelect.Bind(wx.EVT_RADIOBOX, self.onImageQuality)

        self.copyToClipboard = wx.Button(
            self, label=_('Copy Finish Strip to Clipboard'))
        self.copyToClipboard.Bind(wx.EVT_BUTTON, self.onCopyToClipboard)

        fgs = wx.FlexGridSizer(cols=2, vgap=0, hgap=0)
        fgs.Add(wx.StaticText(self, label=u'{}'.format(_('Stretch'))),
                flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTRE_VERTICAL)
        fgs.Add(self.stretchSlider, flag=wx.EXPAND)

        fgs.AddGrowableCol(1, 1)

        hs = wx.BoxSizer(wx.HORIZONTAL)
        hs.Add(self.direction)
        hs.Add(self.imageQualitySelect, flag=wx.LEFT, border=16)
        hs.Add(self.copyToClipboard,
               flag=wx.ALIGN_CENTRE_VERTICAL | wx.LEFT,
               border=16)
        hs.Add(wx.StaticText(self,
                             label=u'\n'.join([
                                 'Pan: Click and Drag',
                                 'Stretch: Mousewheel',
                             ])),
               flag=wx.ALIGN_CENTRE_VERTICAL | wx.LEFT,
               border=16)
        hs.Add(wx.StaticText(self,
                             label=u'\n'.join([
                                 'Zoom: Ctrl+Mousewheel',
                                 'Photo: Right-click',
                             ])),
               flag=wx.ALIGN_CENTRE_VERTICAL | wx.LEFT,
               border=16)
        vs.Add(self.finish, 1, flag=wx.EXPAND)
        vs.Add(self.timeScrollbar, flag=wx.EXPAND)
        vs.Add(fgs, flag=wx.EXPAND | wx.ALL, border=0)
        vs.Add(hs, flag=wx.EXPAND | wx.ALL, border=0)

        self.SetSizer(vs)
        wx.CallAfter(self.initUI)
Пример #10
0
    def __init__(self, parent, owner, items=None):
        wx.Dialog.__init__(self, parent, -1, _("Menu editor"), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
        ADD_ID, REMOVE_ID, NAME_ID, LABEL_ID, ID_ID, CHECK_RADIO_ID, LIST_ID, \
                ADD_SEP_ID, MOVE_LEFT_ID, MOVE_RIGHT_ID, MOVE_UP_ID, \
                MOVE_DOWN_ID, HELP_STR_ID = [wx.NewId() for i in range(13)]

        self._staticbox = wx.StaticBox(self, -1, _("Menu item:"))

        self.owner = owner
        self.menu_items = wx.ListCtrl( self, LIST_ID,
                                       style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.BORDER_SUNKEN|wx.LC_EDIT_LABELS )
        self.menu_items.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.on_label_edited)

        # ALB 2004-09-26: workaround to make the scroll wheel work...
        wx.EVT_MOUSEWHEEL(self.menu_items, lambda e: e.Skip())

        self.menu_items.InsertColumn(0, _("Label"))
        self.menu_items.InsertColumn(1, _("Id"))
        self.menu_items.InsertColumn(2, _("Name"))
        self.menu_items.InsertColumn(3, _("Help String"))
        self.menu_items.InsertColumn(4, _("Type"))
        # ALB 2004-12-05
        self.menu_items.InsertColumn(5, _("Event Handler"))

        self.menu_items.SetColumnWidth(0, 250)
        self.menu_items.SetColumnWidth(2, 250)
        self.menu_items.SetColumnWidth(3, 250)
        self.menu_items.SetColumnWidth(5, 250)

        # menu item fields
        self.id = wx.TextCtrl(self, ID_ID)
        self.label = wx.TextCtrl(self, LABEL_ID)
        self.name = wx.TextCtrl(self, NAME_ID)
        self.help_str = wx.TextCtrl(self, HELP_STR_ID)

        # ALB 2004-12-05
        self.event_handler = wx.TextCtrl(self, -1)
        import re
        self.handler_re = re.compile(r'^\s*\w*\s*$')

        #self.checkable = wx.CheckBox(self, CHECK_ID, "") #Checkable")
        self.check_radio = wx.RadioBox( self, CHECK_RADIO_ID, _("Type"),
                                        choices=['Normal', 'Checkable', 'Radio'], majorDimension=3)

        self.add = wx.Button(self, ADD_ID, _("Add"))
        self.remove = wx.Button(self, REMOVE_ID, _("Remove"))
        self.add_sep = wx.Button(self, ADD_SEP_ID, _("Add separator"))

        # menu items navigation
        self.move_up = wx.Button(self, MOVE_UP_ID, _("Up"))
        self.move_down = wx.Button(self, MOVE_DOWN_ID, _("Down"))
        self.move_left = wx.Button(self, MOVE_LEFT_ID, " < ")
        self.move_right = wx.Button(self, MOVE_RIGHT_ID, " > ")

        self.ok = wx.Button(self, wx.ID_OK, _("OK"))
        self.apply = wx.Button(self, wx.ID_APPLY, _("Apply"))
        self.cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))

        self.do_layout()
        self.selected_index = -1  # index of the selected element in the wx.ListCtrl menu_items
        # event handlers
        wx.EVT_BUTTON(self, ADD_ID, self.add_menu_item)
        wx.EVT_BUTTON(self, REMOVE_ID, self.remove_menu_item)
        wx.EVT_BUTTON(self, ADD_SEP_ID, self.add_separator)
        wx.EVT_BUTTON(self, MOVE_LEFT_ID, self.move_item_left)
        wx.EVT_BUTTON(self, MOVE_RIGHT_ID, self.move_item_right)
        wx.EVT_BUTTON(self, MOVE_UP_ID, self.move_item_up)
        wx.EVT_BUTTON(self, MOVE_DOWN_ID, self.move_item_down)
        wx.EVT_BUTTON(self, wx.ID_APPLY, self.on_apply)
        wx.EVT_KILL_FOCUS(self.name, self.update_menu_item)
        wx.EVT_KILL_FOCUS(self.label, self.update_menu_item)
        wx.EVT_KILL_FOCUS(self.id, self.update_menu_item)
        wx.EVT_KILL_FOCUS(self.help_str, self.update_menu_item)
        # ALB 2004-12-05
        wx.EVT_KILL_FOCUS(self.event_handler, self.update_menu_item)
        #wx.EVT_CHECKBOX(self, CHECK_ID, self.update_menu_item)
        wx.EVT_RADIOBOX(self, CHECK_RADIO_ID, self.update_menu_item)
        wx.EVT_LIST_ITEM_SELECTED(self, LIST_ID, self.show_menu_item)
        if items:
            self.add_items(items)
Пример #11
0
    def __init__(self, *args, **kwds):
        # from *args
        if len(args) == 0:
            dlg = wx.MessageDialog(self, 'Parameters setting error', 'Error',
                                   wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
            return False
        #self.classid = args[0][0]
        #self.kidList = args[0][1]
        #self.adultList = args[0][2]
        self.recordFileName = args[0][0]  #args[0][3]

        # local variables
        self.siteList = self.GetSiteList()
        self.kidList = self.GetKidList()
        self.adultList = self.GetAdultList()

        self.observerList = self.GetObserverList()
        self.classList = self.GetClassList()
        self.activityList = self.GetActivityList()

        self.rndKidList = self.kidList[:]
        self.rndKidList.insert(0, 'Random Select Child')
        self.vaKidList = self.kidList + self.adultList
        self.vaKidList.insert(0, '')
        self.vaKidList.insert(1, '?')
        self.record = None

        self.currentGauge = 1
        self.observerDict = self.GetRoundInfo()
        self.currentObserver = ''

        # GUI
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, None, -1, **kwds)
        self.CreateStatusBar()

        panel = wx.Panel(self, -1)
        self.SetBackgroundColour((217, 241, 255))

        self.label_30 = wx.StaticText(panel, -1, '')
        self.label_31 = wx.StaticText(panel, -1, "Current observation #:")
        self.input1 = wx.TextCtrl(panel, -1, '', (95, 105))

        self.label_20 = wx.StaticText(panel, -1, "Date:")
        self.label_21 = wx.StaticText(panel, -1, "")
        self.label_22 = wx.StaticText(panel, -1, "Observer:")
        self.combo_box_ObserverList = wx.ComboBox(panel,
                                                  -1,
                                                  choices=self.observerList,
                                                  style=wx.CB_DROPDOWN)
        self.label_23 = wx.StaticText(panel, -1, "Class:")
        self.combo_box_ClassList = wx.ComboBox(panel,
                                               -1,
                                               choices=self.classList,
                                               style=wx.CB_DROPDOWN)
        self.label_24 = wx.StaticText(panel, -1, "Round# (today):")
        #roundList = [str(i) for i in range(1,21)]
        #roundList.insert(0,'')
        #self.combo_box_RoundList= wx.ComboBox(panel, -1, choices=roundList, style=wx.CB_DROPDOWN)

        self.label_26 = wx.StaticText(panel, -1, "# Children present:")
        #self.label_27 = wx.StaticText(panel, -1, "")
        numOfChild = [str(i) for i in range(1, len(self.kidList))]
        numOfChild.insert(0, '')
        self.combo_box_ChildrenPresent = wx.ComboBox(panel,
                                                     -1,
                                                     choices=numOfChild,
                                                     style=wx.CB_DROPDOWN)
        self.label_28 = wx.StaticText(panel, -1, "Site:")
        self.combo_box_SiteList = wx.ComboBox(panel,
                                              -1,
                                              choices=self.siteList,
                                              style=wx.CB_DROPDOWN)
        self.label_29 = wx.StaticText(panel, -1, "Activity setting:")
        self.combo_box_ActivityList = wx.ComboBox(panel,
                                                  -1,
                                                  choices=self.activityList,
                                                  style=wx.CB_DROPDOWN)

        self.button_randSelKid = buttons.GenBitmapButton(
            panel, -1, bitRedDice.getsmall_red_diceBitmap(), style=1)
        self.combo_box_RndChildList = wx.ComboBox(panel,
                                                  -1,
                                                  choices=self.rndKidList,
                                                  style=wx.CB_DROPDOWN)
        self.button_StartRecord = wx.Button(panel, -1, "Start Recording")
        self.button_SaveRecord = wx.Button(panel, -1, "Save Record")
        self.button_DiscardRecord = wx.Button(panel, -1, "Discard Record")
        self.gauge_Timer = wx.Gauge(panel, -1, size=(100, 30))
        self.gauge_Timer1 = wx.Gauge(panel, -1, size=(100, 30))
        self.label_6 = wx.StaticText(panel, -1, "Attention:")
        self.radio_box_Attend = wx.RadioBox(panel,
                                            -1,
                                            "",
                                            choices=["N/A", "Glance", "Look"],
                                            majorDimension=0,
                                            style=wx.RA_SPECIFY_ROWS)
        self.label_1 = wx.StaticText(panel, -1, "Joint Attention To:")
        self.label_2 = wx.StaticText(panel, -1, "Attend Target 1:")
        self.combo_box_TargetChildList1 = wx.ComboBox(panel,
                                                      -1,
                                                      choices=self.vaKidList,
                                                      style=wx.CB_DROPDOWN)
        self.label_3 = wx.StaticText(panel, -1, "Attend Target 2:")
        self.combo_box_TargetChildList2 = wx.ComboBox(panel,
                                                      -1,
                                                      choices=self.vaKidList,
                                                      style=wx.CB_DROPDOWN)
        self.label_4 = wx.StaticText(panel, -1, "Attend Target 3:")
        self.combo_box_TargetChildList3 = wx.ComboBox(panel,
                                                      -1,
                                                      choices=self.vaKidList,
                                                      style=wx.CB_DROPDOWN)
        self.label_5 = wx.StaticText(panel, -1, "Attend Target 4:")
        self.combo_box_TargetChildList4 = wx.ComboBox(panel,
                                                      -1,
                                                      choices=self.vaKidList,
                                                      style=wx.CB_DROPDOWN)
        self.label_7 = wx.StaticText(panel, -1, "Affect:")
        self.radio_box_Affect = wx.RadioBox(
            panel,
            -1,
            "",
            choices=["N/A", "Positive", "Neutral", "Negtive"],
            majorDimension=0,
            style=wx.RA_SPECIFY_ROWS)
        self.label_8 = wx.StaticText(panel, -1, "6 seconds timer:")
        self.label_9 = wx.StaticText(
            panel, -1, """
Coder Note: Observe the target child for a period 6-sec.\
Identify each person with whom the target child follows attending behavior.\
Episodes of joint attention are coded as "G" if the child looks briefly (<3-sec) \
at the reference object and coded as "L"\
if the child looks for a longer (>=3-sec).  \
After scoring "G" or "L", record affect.
""")

        self.led = gizmos.LEDNumberCtrl(panel, -1)
        self.__set_properties()
        #self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.RandomSelectChild,
                  self.button_randSelKid)
        self.Bind(wx.EVT_COMBOBOX, self.RandomChildSelected,
                  self.combo_box_RndChildList)
        self.Bind(wx.EVT_BUTTON, self.StartRecord, self.button_StartRecord)
        self.Bind(wx.EVT_BUTTON, self.SaveRecord, self.button_SaveRecord)
        self.Bind(wx.EVT_BUTTON, self.DiscardRecord, self.button_DiscardRecord)
        self.Bind(wx.EVT_COMBOBOX, self.SelectVisualTarget1,
                  self.combo_box_TargetChildList1)
        self.Bind(wx.EVT_COMBOBOX, self.SelectVisualTarget2,
                  self.combo_box_TargetChildList2)
        self.Bind(wx.EVT_COMBOBOX, self.SelectVisualTarget3,
                  self.combo_box_TargetChildList3)
        self.Bind(wx.EVT_COMBOBOX, self.SelectVisualTarget4,
                  self.combo_box_TargetChildList4)
        self.Bind(wx.EVT_RADIOBOX, self.SelectAttend, self.radio_box_Attend)
        self.Bind(wx.EVT_RADIOBOX, self.SelectAffect, self.radio_box_Affect)
        self.Bind(wx.EVT_COMBOBOX, self.ObserverSelected,
                  self.combo_box_ObserverList)
        id1 = wx.NewId()
        wx.RegisterId(id1)
        self.timer = wx.Timer(self, id1)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer, id1)
        id2 = wx.NewId()
        wx.RegisterId(id1)
        self.statusTimer = wx.Timer(self, id2)
        self.Bind(wx.EVT_TIMER, self.OnStatusTimer, self.statusTimer, id2)

        self.count = 0
        self.statusTimer.Start(1000)
        self.OnStatusTimer(None)
Пример #12
0
 def _create_and_add_rb_period(self, form, period_list):
     self.rb_period = wx.RadioBox(self, wx.ID_ANY, _("Period"),
                                  wx.DefaultPosition, wx.DefaultSize,
                                  period_list)
     form.Add(self.rb_period, flag=wx.ALL | wx.EXPAND, border=BORDER)
Пример #13
0
    def __init__(self, parent, pos):
        """The settings mini window."""
        wx.Dialog.__init__(self,
                           parent,
                           id=wx.ID_ANY,
                           title=_(u'TES3lint Settings'),
                           pos=pos,
                           size=(331, 494),
                           style=wx.DEFAULT_DIALOG_STYLE)

        if True:  # Box Sizers
            perl_sizer = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY, _(u'Perl Executable:')),
                wx.HORIZONTAL)
            tesl3int_sizer = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY, _(u'TES3lint Script Location:')),
                wx.HORIZONTAL)
            custom_flags_teslint_sizer = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY, _(u'Custom Flags:')),
                wx.VERTICAL)
            extras_teslint_sizer = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY,
                             _(u'Extra Options (May cause freezes):')),
                wx.VERTICAL)
            result_sizer = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY, _(u'Final Command:')),
                wx.HORIZONTAL)

        if True:  # Content
            # Perl Field/Button:
            self.perl_field = wx.TextCtrl(perl_sizer.GetStaticBox(), wx.ID_ANY,
                                          u'', dPos, dSize, wx.TE_NO_VSCROLL)
            self.browse_perl_btn = wx.Button(perl_sizer.GetStaticBox(),
                                             wx.ID_ANY, u'...', dPos, dSize, 0)
            # TES3lint Field/Button:
            self.tes3lint_field = wx.TextCtrl(tesl3int_sizer.GetStaticBox(),
                                              wx.ID_ANY, u'', dPos, dSize,
                                              wx.TE_NO_VSCROLL)
            self.browse_teslint_btn = wx.Button(tesl3int_sizer.GetStaticBox(),
                                                wx.ID_ANY, u'...', dPos, dSize,
                                                0)
            # Recommended Flags:
            flags_radio_boxChoices = [
                _(u'-n  "normal" output flags on (fastest)'),
                _(u' -r  "recommended" output flags on (slow)'),
                _(u'-a  all output flags on. (slowest)'),
                _(u' -f "flags" specify flags below (separated by comma):')
            ]
            self.flags_radio_box = wx.RadioBox(self, wx.ID_ANY,
                                               u'Recommended Lists of Flags:',
                                               dPos, dSize,
                                               flags_radio_boxChoices, 1, 0)
            self.flags_radio_box.SetSelection(0)
            # Custom Flags:
            self.custom_flags_text = wx.TextCtrl(
                custom_flags_teslint_sizer.GetStaticBox(), wx.ID_ANY, u'',
                dPos, dSize, 0)
            # Extra Options:
            self.debug_checkBox = wx.CheckBox(
                extras_teslint_sizer.GetStaticBox(), wx.ID_ANY,
                _(u'-D  "debug" output (vast)'), dPos, dSize, 0)
            self.verbose_checkBox = wx.CheckBox(
                extras_teslint_sizer.GetStaticBox(), wx.ID_ANY,
                _(u' -v  "verbose" (possibly more output)'), dPos, dSize, 0)
            # TES3lint result:
            self.final_static = wx.StaticText(result_sizer.GetStaticBox(),
                                              wx.ID_ANY, u'', dPos, dSize, 0)
            self.final_static.Wrap(-1)
            # Buttons
            self.ok_btn = wx.Button(self, wx.ID_OK, _(u'OK'), dPos, dSize, 0)
            self.cancel_btn = wx.Button(self, wx.ID_CANCEL, _(u'Cancel'), dPos,
                                        dSize, 0)

        if True:  # Theming
            self.perl_field.SetForegroundColour(wx.Colour(0, 0, 0))
            self.perl_field.SetBackgroundColour(wx.Colour(255, 255, 255))
            self.tes3lint_field.SetForegroundColour(wx.Colour(0, 0, 0))
            self.tes3lint_field.SetBackgroundColour(wx.Colour(255, 255, 255))
            self.custom_flags_text.SetForegroundColour(wx.Colour(0, 0, 0))
            self.custom_flags_text.SetBackgroundColour(wx.Colour(
                255, 255, 255))
            self.final_static.SetForegroundColour(wx.BLUE)
            self.final_static.SetBackgroundColour(wx.Colour(240, 240, 240))

        if True:  # Layout
            perl_sizer.AddMany([(self.perl_field, 1, wx.ALL, 5),
                                (self.browse_perl_btn, 0, wx.ALL, 5)])
            tesl3int_sizer.AddMany([(self.tes3lint_field, 1, wx.ALL, 5),
                                    (self.browse_teslint_btn, 0, wx.ALL, 5)])
            custom_flags_teslint_sizer.Add(self.custom_flags_text, 0,
                                           wx.ALL | wx.EXPAND, 5)
            extras_teslint_sizer.AddMany([(self.debug_checkBox, 0, wx.ALL, 5),
                                          (self.verbose_checkBox, 0, wx.ALL, 5)
                                          ])
            result_sizer.Add(self.final_static, 0, wx.ALL | wx.EXPAND, 5)
            buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
            buttons_sizer.AddMany([(self.ok_btn, 0, wx.ALL, 5), space,
                                   (self.cancel_btn, 0, wx.ALL, 5)])
            main_sizer = wx.BoxSizer(wx.VERTICAL)
            main_sizer.AddMany([(perl_sizer, 0, wx.EXPAND, 5),
                                (tesl3int_sizer, 0, wx.EXPAND, 5),
                                (self.flags_radio_box, 0, wx.ALL | wx.EXPAND,
                                 5),
                                (custom_flags_teslint_sizer, 0, wx.EXPAND, 5),
                                (extras_teslint_sizer, 0, wx.EXPAND, 5),
                                (result_sizer, 0, wx.EXPAND, 5),
                                (buttons_sizer, 0, wx.EXPAND, 5)])
            self.SetSizer(main_sizer)

        if True:  # Events
            self.timer_po()
            self.Bind(wx.EVT_CLOSE, self.OnClose)
            self.ok_btn.Bind(wx.EVT_BUTTON, self.OnOK)
            self.cancel_btn.Bind(wx.EVT_BUTTON, self.OnClose)
            self.browse_perl_btn.Bind(wx.EVT_BUTTON, self.perl_dir)
            self.browse_teslint_btn.Bind(wx.EVT_BUTTON, self.tes3lint_dir)
            self.flags_radio_box.Bind(wx.EVT_RADIOBOX, self.refresh)
            self.Bind(wx.EVT_CHECKBOX, self.refresh)
            self.custom_flags_text.Bind(wx.EVT_TEXT, self.refresh)
            self.tes3lint_field.Bind(wx.EVT_TEXT, self.refresh)

        self.Layout()
        self.import_settings()
        self.ShowModal()
Пример #14
0
    def run_as_data_tool(self):
        from cellprofiler.gui.editobjectsdlg import EditObjectsDialog
        import wx
        from wx.lib.filebrowsebutton import FileBrowseButton
        from cellprofiler.modules.namesandtypes import ObjectsImageProvider
        from bioformats import load_using_bioformats

        with wx.Dialog(None) as dlg:
            dlg.Title = "Choose files for editing"
            dlg.Sizer = wx.BoxSizer(wx.VERTICAL)
            box = wx.StaticBox(dlg, -1, "Choose or create new objects file")
            sub_sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
            dlg.Sizer.Add(sub_sizer, 0, wx.EXPAND | wx.ALL, 5)
            new_or_existing_rb = wx.RadioBox(dlg,
                                             style=wx.RA_VERTICAL,
                                             choices=("New", "Existing"))
            sub_sizer.Add(new_or_existing_rb, 0, wx.EXPAND)
            objects_file_fbb = FileBrowseButton(
                dlg,
                size=(300, -1),
                fileMask=
                "Objects file (*.tif, *.tiff, *.png, *.bmp, *.jpg)|*.tif;*.tiff;*.png;*.bmp;*.jpg",
                dialogTitle="Select objects file",
                labelText="Objects file:")
            objects_file_fbb.Enable(False)
            sub_sizer.AddSpacer(5)
            sub_sizer.Add(objects_file_fbb, 0, wx.ALIGN_TOP | wx.ALIGN_RIGHT)

            def on_radiobox(event):
                objects_file_fbb.Enable(new_or_existing_rb.GetSelection() == 1)

            new_or_existing_rb.Bind(wx.EVT_RADIOBOX, on_radiobox)

            image_file_fbb = FileBrowseButton(
                dlg,
                size=(300, -1),
                fileMask=
                "Objects file (*.tif, *.tiff, *.png, *.bmp, *.jpg)|*.tif;*.tiff;*.png;*.bmp;*.jpg",
                dialogTitle="Select guide image file",
                labelText="Guide image:")
            dlg.Sizer.Add(image_file_fbb, 0, wx.EXPAND | wx.ALL, 5)

            allow_overlap_checkbox = wx.CheckBox(dlg, -1,
                                                 "Allow objects to overlap")
            allow_overlap_checkbox.Value = True
            dlg.Sizer.Add(allow_overlap_checkbox, 0, wx.EXPAND | wx.ALL, 5)

            buttons = wx.StdDialogButtonSizer()
            dlg.Sizer.Add(buttons, 0,
                          wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.ALL,
                          5)
            buttons.Add(wx.Button(dlg, wx.ID_OK))
            buttons.Add(wx.Button(dlg, wx.ID_CANCEL))
            buttons.Realize()
            dlg.Fit()
            result = dlg.ShowModal()
            if result != wx.ID_OK:
                return
            self.allow_overlap.value = allow_overlap_checkbox.Value
            fullname = objects_file_fbb.GetValue()
            guidename = image_file_fbb.GetValue()

        if new_or_existing_rb.GetSelection() == 1:
            provider = ObjectsImageProvider("InputObjects",
                                            pathname2url(fullname), None, None)
            image = provider.provide_image(None)
            pixel_data = image.pixel_data
            shape = pixel_data.shape[:2]
            labels = [pixel_data[:, :, i] for i in range(pixel_data.shape[2])]
        else:
            labels = None
        #
        # Load the guide image
        #
        guide_image = load_using_bioformats(guidename)
        if np.min(guide_image) != np.max(guide_image):
            guide_image = ((guide_image - np.min(guide_image)) /
                           (np.max(guide_image) - np.min(guide_image)))
        if labels is None:
            shape = guide_image.shape[:2]
            labels = [np.zeros(shape, int)]
        with EditObjectsDialog(guide_image, labels, self.allow_overlap,
                               self.object_name.value) as dialog_box:
            result = dialog_box.ShowModal()
            if result != wx.OK:
                return
            labels = dialog_box.labels
        n_frames = len(labels)
        with wx.FileDialog(None,
                           style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as dlg:

            dlg.Path = fullname
            dlg.Wildcard = ("Object image file (*.tif,*.tiff)|*.tif;*.tiff|"
                            "Ilastik project file (*.ilp)|*.ilp")
            result = dlg.ShowModal()
            fullname = dlg.Path
            if result == wx.ID_OK:
                if fullname.endswith(".ilp"):
                    self.save_into_ilp(fullname, labels, guidename)
                else:
                    from bioformats.formatwriter import write_image
                    from bioformats.omexml import PT_UINT16
                    if os.path.exists(fullname):
                        os.unlink(fullname)
                    for i, l in enumerate(labels):
                        write_image(fullname,
                                    l,
                                    PT_UINT16,
                                    t=i,
                                    size_t=len(labels))
Пример #15
0
    def __init__(self, parent, title):
        super(MyFrame, self).__init__(parent, title=title, size=(600, 800))
        self.panel = MyPanel(self)

        # course_id box
        course_id_box = wx.BoxSizer(wx.HORIZONTAL)
        course_id = wx.StaticText(self, label="CourseID:")
        course_id_box.Add(course_id, 0, wx.ALL | wx.CENTER, 5)
        self.course_id = wx.TextCtrl(self)
        course_id_box.Add(self.course_id, 0, wx.ALL, 5)

        # course lecture name

        course_lecture_name_box = wx.BoxSizer(wx.HORIZONTAL)
        course_lecture_name = wx.StaticText(self, label="Lecture Name:")
        course_lecture_name_box.Add(course_lecture_name, 0, wx.ALL | wx.CENTER,
                                    5)
        self.course_lecture_name = wx.TextCtrl(self)
        course_lecture_name_box.Add(self.course_lecture_name, 0, wx.ALL, 5)

        # course_year box
        course_year_box = wx.BoxSizer(wx.HORIZONTAL)
        course_year = wx.StaticText(self, label="CourseYear:")
        course_year_box.Add(course_year, 0, wx.ALL | wx.CENTER, 5)
        self.course_year = wx.TextCtrl(self)
        course_year_box.Add(self.course_year, 0, wx.ALL, 5)

        # what num of lecture/tutorial box
        course_num_box = wx.BoxSizer(wx.HORIZONTAL)
        course_num = wx.StaticText(self, label="hmNum/solNum")
        course_num_box.Add(course_num, 0, wx.ALL | wx.CENTER, 5)
        self.course_num = wx.TextCtrl(self)
        course_num_box.Add(self.course_num, 0, wx.ALL, 5)

        # what part of lectue/tutorial box

        what_kind_of_part_List = ['1', '2', '3']

        self.kind_part = wx.RadioBox(self,
                                     label='Version',
                                     choices=what_kind_of_part_List,
                                     majorDimension=1,
                                     style=wx.RA_SPECIFY_ROWS)
        self.kind_part.Bind(wx.EVT_RADIOBOX, self.OnRadioBox)

        # course semster box

        what_kind_of_semster_List = ['A', 'B', 'C']

        self.kind_semster = wx.RadioBox(self,
                                        label='whatKindOfSemester',
                                        choices=what_kind_of_semster_List,
                                        majorDimension=1,
                                        style=wx.RA_SPECIFY_ROWS)
        self.kind_semster.Bind(wx.EVT_RADIOBOX, self.OnRadioBox)

        # course remarks box

        course_remarks_box = wx.BoxSizer(wx.HORIZONTAL)
        course_remarks = wx.StaticText(self, label="Author:")
        course_remarks_box.Add(course_remarks, 0, wx.ALL | wx.CENTER, 5)
        self.remarks = wx.TextCtrl(self)
        course_remarks_box.Add(self.remarks, 0, wx.ALL, 5)

        # add kind of file ChekeBox
        what_kind_of_file_List = ['HW', 'SOL']

        self.kind_file = wx.RadioBox(self,
                                     label='whatKindOfFile',
                                     choices=what_kind_of_file_List,
                                     majorDimension=1,
                                     style=wx.RA_SPECIFY_ROWS)
        self.kind_file.Bind(wx.EVT_RADIOBOX, self.OnRadioBox)

        # connect
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(course_id_box, 0, wx.ALL, 5)
        main_sizer.Add(course_year_box, 0, wx.ALL, 5)
        main_sizer.Add(course_lecture_name_box, 0, wx.ALL, 5)
        main_sizer.Add(course_num_box, 0, wx.ALL, 5)
        main_sizer.Add(self.kind_part, 0, wx.ALL, 5)
        main_sizer.Add(self.kind_semster, 0, wx.ALL, 5)
        main_sizer.Add(self.kind_file, 0, wx.ALL, 5)
        main_sizer.Add(course_remarks_box, 0, wx.ALL, 5)

        # add File

        btn = wx.Button(self, label="AddFile")
        btn.Bind(wx.EVT_BUTTON, self.OnAddFile)
        main_sizer.Add(btn, 0, wx.ALL | wx.CENTER, 5)

        # update to google drive

        btn1 = wx.Button(self, label="UpdateToOneDrive")
        btn1.Bind(wx.EVT_BUTTON, self.OnUpdate)
        main_sizer.Add(btn1, 0, wx.ALL | wx.CENTER, 5)

        self.SetSizer(main_sizer)
Пример #16
0
    def run_mouse(self, background_image, image_set_number):
        """Define a grid by running the UI

        Returns a CPGridInfo object
        """
        import matplotlib
        import matplotlib.backends.backend_wxagg as backend
        import wx
        from wx.lib.intctrl import IntCtrl

        #
        # Make up a dialog box. It has the following structure:
        #
        # Dialog:
        #    top_sizer:
        #        Canvas
        #            Figure
        #               Axis
        #        control_sizer
        #            first_sizer
        #               first_row
        #               first_col
        #            second_sizer
        #               second_row
        #               second_col
        #            button_sizer
        #               Redisplay
        #               OK
        #               cancel
        #    status bar
        #
        figure = matplotlib.figure.Figure()
        frame = wx.Dialog(
            wx.GetApp().TopWindow,
            title="Select grid cells, image cycle #%d:" % (image_set_number),
        )
        top_sizer = wx.BoxSizer(wx.VERTICAL)
        frame.SetSizer(top_sizer)
        canvas = backend.FigureCanvasWxAgg(frame, -1, figure)
        top_sizer.Add(canvas, 1, wx.EXPAND)
        top_sizer.Add(
            wx.StaticText(
                frame,
                -1,
                "Select the center of a grid cell with the left mouse button.\n",
            ),
            0,
            wx.EXPAND | wx.ALL,
            5,
        )
        control_sizer = wx.BoxSizer(wx.HORIZONTAL)
        top_sizer.Add(control_sizer, 0, wx.EXPAND | wx.ALL, 5)
        FIRST_CELL = "First cell"
        SECOND_CELL = "Second cell"
        cell_choice = wx.RadioBox(
            frame,
            label="Choose current cell",
            choices=[FIRST_CELL, SECOND_CELL],
            style=wx.RA_VERTICAL,
        )
        control_sizer.Add(cell_choice)
        #
        # Text boxes for the first cell's row and column
        #
        first_sizer = wx.GridBagSizer(2, 2)
        control_sizer.Add(first_sizer, 1, wx.EXPAND | wx.ALL, 5)
        first_sizer.Add(
            wx.StaticText(frame, -1, "First cell column:"),
            wx.GBPosition(0, 0),
            flag=wx.EXPAND,
        )
        first_column = IntCtrl(frame,
                               -1,
                               1,
                               min=1,
                               max=self.grid_columns.value)
        first_sizer.Add(first_column, wx.GBPosition(0, 1), flag=wx.EXPAND)
        first_sizer.Add(
            wx.StaticText(frame, -1, "First cell row:"),
            wx.GBPosition(1, 0),
            flag=wx.EXPAND,
        )
        first_row = IntCtrl(frame, -1, 1, min=1, max=self.grid_rows.value)
        first_sizer.Add(first_row, wx.GBPosition(1, 1), flag=wx.EXPAND)
        first_sizer.Add(wx.StaticText(frame, -1, "X:"), wx.GBPosition(0, 2))
        first_x = IntCtrl(frame, -1, 100, min=1)
        first_sizer.Add(first_x, wx.GBPosition(0, 3))
        first_sizer.Add(wx.StaticText(frame, -1, "Y:"), wx.GBPosition(1, 2))
        first_y = IntCtrl(frame, -1, 100, min=1)
        first_sizer.Add(first_y, wx.GBPosition(1, 3))
        #
        # Text boxes for the second cell's row and column
        #
        second_sizer = wx.GridBagSizer(2, 2)
        control_sizer.Add(second_sizer, 1, wx.EXPAND | wx.ALL, 5)
        second_sizer.Add(
            wx.StaticText(frame, -1, "Second cell column:"),
            wx.GBPosition(0, 0),
            flag=wx.EXPAND,
        )
        second_column = IntCtrl(frame,
                                -1,
                                self.grid_columns.value,
                                min=1,
                                max=self.grid_columns.value)
        second_sizer.Add(second_column, wx.GBPosition(0, 1), flag=wx.EXPAND)
        second_sizer.Add(
            wx.StaticText(frame, -1, "Second cell row:"),
            wx.GBPosition(1, 0),
            flag=wx.EXPAND,
        )
        second_row = IntCtrl(frame,
                             -1,
                             self.grid_rows.value,
                             min=1,
                             max=self.grid_rows.value)
        second_sizer.Add(second_row, wx.GBPosition(1, 1), flag=wx.EXPAND)
        second_sizer.Add(wx.StaticText(frame, -1, "X:"), wx.GBPosition(0, 2))
        second_x = IntCtrl(frame, -1, 200, min=1)
        second_sizer.Add(second_x, wx.GBPosition(0, 3))
        second_sizer.Add(wx.StaticText(frame, -1, "Y:"), wx.GBPosition(1, 2))
        second_y = IntCtrl(frame, -1, 200, min=1)
        second_sizer.Add(second_y, wx.GBPosition(1, 3))
        #
        # Buttons
        #
        button_sizer = wx.BoxSizer(wx.VERTICAL)
        control_sizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 5)
        redisplay_button = wx.Button(frame, -1, "Redisplay")
        button_sizer.Add(redisplay_button)
        button_sizer.Add(wx.Button(frame, wx.OK, "OK"))
        button_sizer.Add(wx.Button(frame, wx.CANCEL, "Cancel"))
        #
        # Status bar
        #
        status_bar = wx.StatusBar(frame, style=0)
        top_sizer.Add(status_bar, 0, wx.EXPAND)
        status_bar.SetFieldsCount(1)
        SELECT_FIRST_CELL = "Select the center of the first cell"
        SELECT_SECOND_CELL = "Select the center of the second cell"
        status_bar.SetStatusText(SELECT_FIRST_CELL)
        status = [wx.OK]
        gridding = [None]
        if self.display_image_name == "Leave blank":
            image_shape = None
        else:
            image_shape = background_image.shape[:2]

        def redisplay(event):
            figure.clf()
            axes = figure.add_subplot(1, 1, 1)

            if (event is not None) or (gridding[0] is None):
                do_gridding(first_x.Value, first_y.Value, second_x.Value,
                            second_y.Value)
            self.display_grid(background_image, gridding[0], image_set_number,
                              axes)
            canvas.draw()

        def cancel(event):
            status[0] = wx.CANCEL
            frame.SetReturnCode(wx.CANCEL)
            frame.Close(True)

        def ok(event):
            status[0] = wx.OK
            frame.SetReturnCode(wx.OK)
            frame.Close(True)

        def on_cell_selection(event):
            if cell_choice.Selection == 0:
                status_bar.SetStatusText(SELECT_FIRST_CELL)
            else:
                status_bar.SetStatusText(SELECT_SECOND_CELL)

        def do_gridding(x1, y1, x2, y2):
            try:
                gridding[0] = self.build_grid_info(
                    int(x1),
                    int(y1),
                    int(first_row.Value),
                    int(first_column.Value),
                    int(x2),
                    int(y2),
                    int(second_row.Value),
                    int(second_column.Value),
                    image_shape,
                )
            except Exception as e:
                logger.error(e.message, exc_info=True)
                status_bar.SetStatusText(e.message)
                return False
            return True

        def button_release(event):
            if event.inaxes == figure.axes[0]:
                if cell_choice.Selection == 0:
                    new_first_x = str(int(event.xdata))
                    new_first_y = str(int(event.ydata))
                    if do_gridding(new_first_x, new_first_y, second_x.Value,
                                   second_y.Value):
                        first_x.Value = new_first_x
                        first_y.Value = new_first_y
                        cell_choice.Selection = 1
                        status_bar.SetStatusText(SELECT_SECOND_CELL)
                else:
                    new_second_x = str(int(event.xdata))
                    new_second_y = str(int(event.ydata))
                    if do_gridding(first_x.Value, first_y.Value, new_second_x,
                                   new_second_y):
                        second_x.Value = new_second_x
                        second_y.Value = new_second_y
                        cell_choice.Selection = 0
                        status_bar.SetStatusText(SELECT_FIRST_CELL)
                redisplay(None)

        redisplay(None)
        frame.Fit()
        frame.Bind(wx.EVT_BUTTON, redisplay, redisplay_button)
        frame.Bind(wx.EVT_BUTTON, cancel, id=wx.CANCEL)
        frame.Bind(wx.EVT_BUTTON, ok, id=wx.OK)
        frame.Bind(wx.EVT_RADIOBOX, on_cell_selection, cell_choice)
        canvas.mpl_connect("button_release_event", button_release)
        frame.ShowModal()
        do_gridding(first_x.Value, first_y.Value, second_x.Value,
                    second_y.Value)
        frame.Destroy()
        if status[0] != wx.OK:
            raise RuntimeError("Pipeline aborted during grid editing")
        return gridding[0]
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(
            self,
            id=wxID_FRAMEEDICAOFUNCIONARIO,
            name=u'frameEdicaoFuncionario',
            parent=prnt,
            pos=wx.Point(700, 273),
            size=wx.Size(1040, 614),
            style=wx.DEFAULT_FRAME_STYLE,
            title=u'Est\xe1gio Curricular - Edi\xe7\xe3o de Funcion\xe1rios')
        self.SetClientSize(wx.Size(1024, 576))
        self.Center(wx.BOTH)
        self.SetIcon(wx.Icon(u'./Graficos/icone.ico', wx.BITMAP_TYPE_ICO))
        self.SetMaxSize(wx.Size(1040, 614))
        self.SetMinSize(wx.Size(1040, 614))

        self.painelEdicaoFuncionario = wx.Panel(
            id=wxID_FRAMEEDICAOFUNCIONARIOPAINELEDICAOFUNCIONARIO,
            name=u'painelEdicaoFuncionario',
            parent=self,
            pos=wx.Point(0, 0),
            size=wx.Size(1024, 576),
            style=wx.TAB_TRAVERSAL)
        self.painelEdicaoFuncionario.SetBackgroundColour(
            wx.Colour(255, 255, 255))

        self.nomeLogin = wx.StaticText(id=wxID_FRAMEEDICAOFUNCIONARIONOMELOGIN,
                                       label=u'Login:'******'nomeLogin',
                                       parent=self.painelEdicaoFuncionario,
                                       pos=wx.Point(12, 127),
                                       size=wx.Size(30, 13),
                                       style=0)

        self.campoLogin = wx.TextCtrl(id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOLOGIN,
                                      name=u'campoLogin',
                                      parent=self.painelEdicaoFuncionario,
                                      pos=wx.Point(25, 148),
                                      size=wx.Size(224, 21),
                                      style=0,
                                      value=u'')

        self.botaoCarregar = wx.BitmapButton(
            bitmap=wx.Bitmap(u'./Graficos/botao_carregar.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOCARREGAR,
            name=u'botaoCarregar',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(262, 144),
            size=wx.Size(26, 27),
            style=wx.BU_AUTODRAW)

        self.logoIFPE = wx.StaticBitmap(bitmap=wx.Bitmap(
            u'./Graficos/logo.png', wx.BITMAP_TYPE_PNG),
                                        id=wxID_FRAMEEDICAOFUNCIONARIOLOGOIFPE,
                                        name=u'logoIFPE',
                                        parent=self.painelEdicaoFuncionario,
                                        pos=wx.Point(8, 8),
                                        size=wx.Size(175, 70),
                                        style=0)

        self.linhaCadastroFuncionarios = wx.StaticBitmap(
            bitmap=wx.Bitmap(u'./Graficos/LinhaEdicaoFuncionarios.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOLINHACADASTROFUNCIONARIOS,
            name=u'linhaCadastroFuncionarios',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(0, 80),
            size=wx.Size(1024, 21),
            style=0)

        self.nomeCPF = wx.StaticText(id=wxID_FRAMEEDICAOFUNCIONARIONOMECPF,
                                     label=u'CPF:',
                                     name=u'nomeCPF',
                                     parent=self.painelEdicaoFuncionario,
                                     pos=wx.Point(11, 185),
                                     size=wx.Size(24, 13),
                                     style=0)

        self.campoCPF = wx.lib.masked.textctrl.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOCPF,
            name=u'campoCPF',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(24, 203),
            size=wx.Size(104, 21),
            style=0,
            value=u'')
        self.campoCPF.SetMask(u'XXX.XXX.XXX-XX')
        self.campoCPF.SetAutoformat('')
        self.campoCPF.SetFormatcodes('')
        self.campoCPF.SetDescription('')
        self.campoCPF.SetExcludeChars('')
        self.campoCPF.SetValidRegex('')
        self.campoCPF.SetMaxLength(14)
        self.campoCPF.SetFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Tahoma'))
        self.campoCPF.SetDefaultEncoding(u'latin1')
        self.campoCPF.SetFillChar(u' ')

        self.CPFInvalido = wx.StaticBitmap(
            bitmap=wx.Bitmap(u'./Graficos/botao_invalido.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOCPFINVALIDO,
            name=u'CPFInvalido',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(170, 205),
            size=wx.Size(14, 14),
            style=0)
        self.CPFInvalido.Show(False)

        self.validarCPF = wx.BitmapButton(
            bitmap=wx.Bitmap(u'./Graficos/botao_buscar.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOVALIDARCPF,
            name=u'validarCPF',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(134, 199),
            size=wx.Size(26, 26),
            style=wx.BU_AUTODRAW)
        self.validarCPF.Bind(wx.EVT_BUTTON,
                             self.OnValidarCPFButton,
                             id=wxID_FRAMEEDICAOFUNCIONARIOVALIDARCPF)

        self.dataNascimento = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIODATANASCIMENTO,
            label=u'Data de nascimento:',
            name=u'dataNascimento',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(202, 183),
            size=wx.Size(100, 13),
            style=0)

        self.campoAniversario = wx.lib.masked.textctrl.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOANIVERSARIO,
            name=u'campoAniversario',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(215, 202),
            size=wx.Size(104, 21),
            style=0,
            value=u'')
        self.campoAniversario.SetMask(u'XX/XX/XXXX')
        self.campoAniversario.SetAutoformat('')
        self.campoAniversario.SetFormatcodes('')
        self.campoAniversario.SetDescription('')
        self.campoAniversario.SetExcludeChars('')
        self.campoAniversario.SetValidRegex('')
        self.campoAniversario.SetMaxLength(10)
        self.campoAniversario.SetFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Tahoma'))
        self.campoAniversario.SetDatestyle('MDY')

        self.selecionaSexo = wx.RadioBox(
            choices=['Feminino', 'Masculino'],
            id=wxID_FRAMEEDICAOFUNCIONARIOSELECIONASEXO,
            label=u'Sexo:',
            majorDimension=1,
            name=u'selecionaSexo',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(342, 183),
            size=wx.Size(176, 43),
            style=wx.RA_SPECIFY_ROWS)
        self.selecionaSexo.SetStringSelection(u'Feminino')

        self.nomeNomeAluno = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMENOMEALUNO,
            label=u'Nome Completo:',
            name=u'nomeNomeAluno',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(11, 239),
            size=wx.Size(80, 13),
            style=0)

        self.campoNomeFuncionario = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPONOMEFUNCIONARIO,
            name=u'campoNomeFuncionario',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(24, 258),
            size=wx.Size(496, 21),
            style=0,
            value=u'')
        self.campoNomeFuncionario.SetMaxLength(50)
        self.campoNomeFuncionario.SetToolTipString(u'campoNomeFuncionario')

        self.nomeCEP = wx.StaticText(id=wxID_FRAMEEDICAOFUNCIONARIONOMECEP,
                                     label=u'CEP:',
                                     name=u'nomeCEP',
                                     parent=self.painelEdicaoFuncionario,
                                     pos=wx.Point(11, 293),
                                     size=wx.Size(24, 13),
                                     style=0)

        self.campoCEP = wx.lib.masked.textctrl.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOCEP,
            name=u'campoCEP',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(24, 312),
            size=wx.Size(104, 21),
            style=0,
            value=u'  .   -   ')
        self.campoCEP.SetMask(u'XX.XXX-XXX')
        self.campoCEP.SetAutoformat('')
        self.campoCEP.SetFormatcodes('')
        self.campoCEP.SetDescription('')
        self.campoCEP.SetExcludeChars('')
        self.campoCEP.SetValidRegex('')
        self.campoCEP.SetMaxLength(10)
        self.campoCEP.SetFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Tahoma'))
        self.campoCEP.SetDatestyle('MDY')

        self.botaoBuscarCEP = wx.BitmapButton(
            bitmap=wx.Bitmap(u'./Graficos/botao_buscar.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOBUSCARCEP,
            name=u'botaoBuscarCEP',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(136, 309),
            size=wx.Size(26, 26),
            style=wx.BU_AUTODRAW)
        self.botaoBuscarCEP.Bind(wx.EVT_BUTTON,
                                 self.OnBotaoBuscarCEPButton,
                                 id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOBUSCARCEP)

        self.nomeNumero = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMENUMERO,
            label=u'N\xfamero:',
            name=u'nomeNumero',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(160, 293),
            size=wx.Size(42, 13),
            style=0)

        self.campoNumero = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPONUMERO,
            name=u'campoNumero',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(173, 312),
            size=wx.Size(100, 21),
            style=0,
            value=u'')

        self.nomeComplemento = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMECOMPLEMENTO,
            label=u'Complemento:',
            name=u'nomeComplemento',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(293, 293),
            size=wx.Size(70, 13),
            style=0)

        self.campoComplemento = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOCOMPLEMENTO,
            name=u'campoComplemento',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(306, 312),
            size=wx.Size(214, 21),
            style=0,
            value=u'')
        self.campoComplemento.SetToolTipString(u'campoComplemento')

        self.nomeEndereco = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMEENDERECO,
            label=u'Endere\xe7o:',
            name=u'nomeEndereco',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(11, 348),
            size=wx.Size(50, 13),
            style=0)

        self.campoEndereco = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOENDERECO,
            name=u'campoEndereco',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(24, 369),
            size=wx.Size(496, 21),
            style=0,
            value=u'')

        self.nomeBairro = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMEBAIRRO,
            label=u'Bairro:',
            name=u'nomeBairro',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(11, 402),
            size=wx.Size(33, 13),
            style=0)

        self.campoBairro = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOBAIRRO,
            name=u'campoBairro',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(24, 421),
            size=wx.Size(224, 21),
            style=0,
            value=u'')

        self.nomeCidade = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMECIDADE,
            label=u'Cidade:',
            name=u'nomeCidade',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(265, 402),
            size=wx.Size(38, 13),
            style=0)

        self.campoCidade = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOCIDADE,
            name=u'campoCidade',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(278, 421),
            size=wx.Size(186, 21),
            style=0,
            value=u'')

        self.nomeUF = wx.StaticText(id=wxID_FRAMEEDICAOFUNCIONARIONOMEUF,
                                    label=u'UF:',
                                    name=u'nomeUF',
                                    parent=self.painelEdicaoFuncionario,
                                    pos=wx.Point(480, 402),
                                    size=wx.Size(18, 13),
                                    style=0)

        self.campoUF = wx.TextCtrl(id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOUF,
                                   name=u'campoUF',
                                   parent=self.painelEdicaoFuncionario,
                                   pos=wx.Point(493, 421),
                                   size=wx.Size(27, 21),
                                   style=0,
                                   value=u'')
        self.campoUF.SetMaxLength(2)

        self.nomeTelefone = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMETELEFONE,
            label=u'Telefone:',
            name=u'nomeTelefone',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(11, 449),
            size=wx.Size(47, 13),
            style=0)

        self.campoTelefone = wx.lib.masked.textctrl.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOTELEFONE,
            name=u'campoTelefone',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(24, 468),
            size=wx.Size(136, 21),
            style=0,
            value=u'(  )    -    ')
        self.campoTelefone.SetAutoformat('')
        self.campoTelefone.SetMask(u'(XX)XXXX-XXXX')
        self.campoTelefone.SetFormatcodes('')
        self.campoTelefone.SetDescription('')
        self.campoTelefone.SetExcludeChars('')
        self.campoTelefone.SetValidRegex('')
        self.campoTelefone.SetMaxLength(13)
        self.campoTelefone.SetFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Tahoma'))

        self.nomeCelular = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMECELULAR,
            label=u'Celular:',
            name=u'nomeCelular',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(175, 451),
            size=wx.Size(38, 13),
            style=0)

        self.campoCelular = wx.lib.masked.textctrl.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOCELULAR,
            name=u'campoCelular',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(188, 470),
            size=wx.Size(136, 21),
            style=0,
            value=u'')
        self.campoCelular.SetAutoformat('')
        self.campoCelular.SetMask(u'(XX)XXXX-XXXX')
        self.campoCelular.SetFormatcodes('')
        self.campoCelular.SetDescription('')
        self.campoCelular.SetExcludeChars('')
        self.campoCelular.SetValidRegex('')
        self.campoCelular.SetMaxLength(13)
        self.campoCelular.SetFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Tahoma'))

        self.selecionaTipoUsuario = wx.RadioBox(
            choices=['Administrador', 'Operador'],
            id=wxID_FRAMEEDICAOFUNCIONARIOSELECIONATIPOUSUARIO,
            label=u'Tipo de Usu\xe1rio:',
            majorDimension=1,
            name=u'selecionaTipoUsuario',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(335, 449),
            size=wx.Size(184, 43),
            style=wx.RA_SPECIFY_ROWS)
        self.selecionaTipoUsuario.SetStringSelection(u'Operador')

        self.nomeSenha = wx.StaticText(id=wxID_FRAMEEDICAOFUNCIONARIONOMESENHA,
                                       label=u'Senha:',
                                       name=u'nomeSenha',
                                       parent=self.painelEdicaoFuncionario,
                                       pos=wx.Point(11, 499),
                                       size=wx.Size(35, 13),
                                       style=0)

        self.campoSenha = wx.TextCtrl(id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOSENHA,
                                      name=u'campoSenha',
                                      parent=self.painelEdicaoFuncionario,
                                      pos=wx.Point(24, 520),
                                      size=wx.Size(224, 21),
                                      style=wx.TE_PASSWORD,
                                      value=u'')

        self.nomeConfimarSenha = wx.StaticText(
            id=wxID_FRAMEEDICAOFUNCIONARIONOMECONFIMARSENHA,
            label=u'Confirmar Senha:',
            name=u'nomeConfimarSenha',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(282, 499),
            size=wx.Size(85, 13),
            style=0)

        self.campoConfirmarSenha = wx.TextCtrl(
            id=wxID_FRAMEEDICAOFUNCIONARIOCAMPOCONFIRMARSENHA,
            name=u'campoConfirmarSenha',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(296, 520),
            size=wx.Size(224, 21),
            style=wx.TE_PASSWORD,
            value=u'')

        self.botaoSalvar = wx.Button(id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOSALVAR,
                                     label=u'Salvar',
                                     name=u'botaoSalvar',
                                     parent=self.painelEdicaoFuncionario,
                                     pos=wx.Point(920, 536),
                                     size=wx.Size(75, 23),
                                     style=0)
        self.botaoSalvar.Bind(wx.EVT_BUTTON,
                              self.OnBotaoSalvarButton,
                              id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOSALVAR)

        self.cpfValido = wx.StaticBitmap(
            bitmap=wx.Bitmap(u'./Graficos/botao_valido.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOCPFVALIDO,
            name=u'cpfValido',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(170, 205),
            size=wx.Size(14, 14),
            style=0)
        self.cpfValido.Show(False)

        self.botaoVoltar = wx.BitmapButton(
            bitmap=wx.Bitmap(u'./Graficos/botao_voltar.png',
                             wx.BITMAP_TYPE_PNG),
            id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOVOLTAR,
            name=u'botaoVoltar',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(952, 13),
            size=wx.Size(57, 57),
            style=wx.BU_AUTODRAW)
        self.botaoVoltar.Bind(wx.EVT_BUTTON,
                              self.OnBotaoVoltarButton,
                              id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOVOLTAR)

        self.botaoLimparFuncionario = wx.Button(
            id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOLIMPARFUNCIONARIO,
            label=u'Limpar',
            name=u'botaoLimparFuncionario',
            parent=self.painelEdicaoFuncionario,
            pos=wx.Point(880, 129),
            size=wx.Size(75, 23),
            style=0)
        self.botaoLimparFuncionario.Bind(
            wx.EVT_BUTTON,
            self.OnBotaoLimparFuncionarioButton,
            id=wxID_FRAMEEDICAOFUNCIONARIOBOTAOLIMPARFUNCIONARIO)

        self.nomeErro = wx.StaticText(id=wxID_FRAMEEDICAOFUNCIONARIONOMEERRO,
                                      label=u'',
                                      name=u'nomeErro',
                                      parent=self.painelEdicaoFuncionario,
                                      pos=wx.Point(544, 144),
                                      size=wx.Size(0, 13),
                                      style=0)
        self.nomeErro.SetAutoLayout(True)
        self.nomeErro.SetFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, True, u'Tahoma'))
Пример #18
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)
        self.log = log

        self.mainpanel = wx.Panel(self, -1)
        self.sizer_5_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 2")
        self.sizer_7_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 3")
        self.sizer_8_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 4")
        self.sizer_4_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 1")
        self.helptext = wx.StaticText(self.mainpanel, -1,
                                      "Welcome to the FloatSpin Demo")

        self.floatspin1 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=0,
                                       max_val=1,
                                       increment=0.01,
                                       value=0.1,
                                       agwStyle=FS.FS_LEFT)
        self.floatspin1.SetFormat("%f")
        self.floatspin1.SetDigits(2)

        self.setvalue1 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue1 = wx.TextCtrl(self.mainpanel, -1, "0.0")
        self.setdigits1 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits1 = wx.TextCtrl(self.mainpanel, -1, "2")
        self.radioformat1 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement1 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr1 = wx.TextCtrl(self.mainpanel, -1, "0.01")
        self.setfont1 = wx.Button(self.mainpanel, -1, "Set Font")

        self.floatspin2 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=-10,
                                       max_val=100,
                                       increment=0.1,
                                       agwStyle=FS.FS_RIGHT)
        self.floatspin2.SetFormat("%e")
        self.floatspin2.SetDigits(4)

        self.setvalue2 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue2 = wx.TextCtrl(self.mainpanel, -1, "0.0")
        self.setdigits2 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits2 = wx.TextCtrl(self.mainpanel, -1, "4")
        self.radioformat2 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement2 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr2 = wx.TextCtrl(self.mainpanel, -1, "0.1")
        self.setfont2 = wx.Button(self.mainpanel, -1, "Set Font")

        self.floatspin3 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=0.01,
                                       max_val=0.05,
                                       increment=0.0001,
                                       agwStyle=FS.FS_CENTRE)
        self.floatspin3.SetFormat("%f")
        self.floatspin3.SetDigits(5)

        self.setvalue3 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue3 = wx.TextCtrl(self.mainpanel, -1, "0.01")
        self.setdigits3 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits3 = wx.TextCtrl(self.mainpanel, -1, "5")
        self.radioformat3 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement3 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr3 = wx.TextCtrl(self.mainpanel, -1, "0.0001")
        self.setfont3 = wx.Button(self.mainpanel, -1, "Set Font")

        self.floatspin4 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=-2,
                                       max_val=20000,
                                       increment=0.1,
                                       agwStyle=FS.FS_READONLY)
        self.floatspin4.SetFormat("%G")
        self.floatspin4.SetDigits(3)

        self.setvalue4 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue4 = wx.TextCtrl(self.mainpanel, -1, "0.0")
        self.setdigits4 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits4 = wx.TextCtrl(self.mainpanel, -1, "3")
        self.radioformat4 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement4 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr4 = wx.TextCtrl(self.mainpanel, -1, "0.1")
        self.setfont4 = wx.Button(self.mainpanel, -1, "Set Font")

        self.valuebuttons = [
            self.setvalue1, self.setvalue2, self.setvalue3, self.setvalue4
        ]
        self.digitbuttons = [
            self.setdigits1, self.setdigits2, self.setdigits3, self.setdigits4
        ]
        self.radioboxes = [
            self.radioformat1, self.radioformat2, self.radioformat3,
            self.radioformat4
        ]
        self.incrbuttons = [
            self.setincrement1, self.setincrement2, self.setincrement3,
            self.setincrement4
        ]
        self.fontbuttons = [
            self.setfont1, self.setfont2, self.setfont3, self.setfont4
        ]
        self.textvalues = [
            self.textctrlvalue1, self.textctrlvalue2, self.textctrlvalue3,
            self.textctrlvalue4
        ]
        self.textdigits = [
            self.textctrldigits1, self.textctrldigits2, self.textctrldigits3,
            self.textctrldigits4
        ]
        self.textincr = [
            self.textctrlincr1, self.textctrlincr2, self.textctrlincr3,
            self.textctrlincr4
        ]
        self.floatspins = [
            self.floatspin1, self.floatspin2, self.floatspin3, self.floatspin4
        ]

        self.SetProperties()
        self.DoLayout()
        self.BindEvents()
Пример #19
0
    def __init__(self, parent, id, title, size, findString=None):
        wx.Dialog.__init__(self, parent, id, title, size=size)

        config = wx.ConfigBase_Get()
        borderSizer = wx.BoxSizer(wx.VERTICAL)
        gridSizer = wx.GridBagSizer(SPACE, SPACE)

        gridSizer2 = wx.GridBagSizer(SPACE, SPACE)
        gridSizer2.Add(wx.StaticText(self, -1, _("Find what:")),
                       flag=wx.ALIGN_CENTER_VERTICAL,
                       pos=(0, 0))
        if not findString:
            findString = config.Read(FIND_MATCHPATTERN, "")
        self._findCtrl = wx.TextCtrl(self, -1, findString, size=(200, -1))
        gridSizer2.Add(self._findCtrl, pos=(0, 1))
        gridSizer2.Add(wx.StaticText(self, -1, _("Replace with:")),
                       flag=wx.ALIGN_CENTER_VERTICAL,
                       pos=(1, 0))
        self._replaceCtrl = wx.TextCtrl(self,
                                        -1,
                                        config.Read(FIND_MATCHREPLACE, ""),
                                        size=(200, -1))
        gridSizer2.Add(self._replaceCtrl, pos=(1, 1))
        gridSizer.Add(gridSizer2, pos=(0, 0), span=(1, 2))
        choiceSizer = wx.BoxSizer(wx.VERTICAL)
        self._wholeWordCtrl = wx.CheckBox(self, -1, _("Match whole word only"))
        self._wholeWordCtrl.SetValue(config.ReadInt(FIND_MATCHWHOLEWORD,
                                                    False))
        self._matchCaseCtrl = wx.CheckBox(self, -1, _("Match case"))
        self._matchCaseCtrl.SetValue(config.ReadInt(FIND_MATCHCASE, False))
        self._regExprCtrl = wx.CheckBox(self, -1, _("Regular expression"))
        self._regExprCtrl.SetValue(config.ReadInt(FIND_MATCHREGEXPR, False))
        self._wrapCtrl = wx.CheckBox(self, -1, _("Wrap"))
        self._wrapCtrl.SetValue(config.ReadInt(FIND_MATCHWRAP, False))
        choiceSizer.Add(self._wholeWordCtrl, 0, wx.BOTTOM, SPACE)
        choiceSizer.Add(self._matchCaseCtrl, 0, wx.BOTTOM, SPACE)
        choiceSizer.Add(self._regExprCtrl, 0, wx.BOTTOM, SPACE)
        choiceSizer.Add(self._wrapCtrl, 0)
        gridSizer.Add(choiceSizer, pos=(1, 0), span=(2, 1))

        self._radioBox = wx.RadioBox(self,
                                     -1,
                                     _("Direction"),
                                     choices=["Up", "Down"])
        self._radioBox.SetSelection(config.ReadInt(FIND_MATCHUPDOWN, 1))
        gridSizer.Add(self._radioBox, pos=(1, 1), span=(2, 1))

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        findBtn = wx.Button(self, FindService.FINDONE_ID, _("Find Next"))
        findBtn.SetDefault()
        wx.EVT_BUTTON(self, FindService.FINDONE_ID, self.OnActionEvent)
        cancelBtn = wx.Button(self, wx.ID_CANCEL)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnClose)
        replaceBtn = wx.Button(self, FindService.REPLACEONE_ID, _("Replace"))
        wx.EVT_BUTTON(self, FindService.REPLACEONE_ID, self.OnActionEvent)
        replaceAllBtn = wx.Button(self, FindService.REPLACEALL_ID,
                                  _("Replace All"))
        wx.EVT_BUTTON(self, FindService.REPLACEALL_ID, self.OnActionEvent)

        BTM_SPACE = HALF_SPACE
        if wx.Platform == "__WXMAC__":
            BTM_SPACE = SPACE

        buttonSizer.Add(findBtn, 0, wx.BOTTOM, BTM_SPACE)
        buttonSizer.Add(replaceBtn, 0, wx.BOTTOM, BTM_SPACE)
        buttonSizer.Add(replaceAllBtn, 0, wx.BOTTOM, BTM_SPACE)
        buttonSizer.Add(cancelBtn, 0)
        gridSizer.Add(buttonSizer, pos=(0, 2), span=(3, 1))

        borderSizer.Add(gridSizer, 0, wx.ALL, SPACE)

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.SetSizer(borderSizer)
        self.Fit()
        self._findCtrl.SetFocus()
    def __init__(self):
        wx.Frame.__init__(self,
                          parent=None,
                          title=u'量化软件',
                          size=(1500, 800),
                          style=wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX)
        #创建显示区面板
        self.DispPanel = MPL_Panel_Base(self)
        self.BackPanel = Loop_Panel_Base(self)
        self.am = self.DispPanel.am
        self.vol = self.DispPanel.vol
        self.devol = self.DispPanel.devol
        self.macd = self.DispPanel.macd

        #创建参数区面板
        self.ParaPanel = wx.Panel(self, -1)

        paraInput_Box = wx.StaticBox(self.ParaPanel, -1, u'参数输入')
        paraInput_Sizer = wx.StaticBoxSizer(paraInput_Box, wx.VERTICAL)
        self.StNameCodedict = {
            u"开山股份": "300257.SZ",
            u"浙大网新": "600797.SS",
            u"水晶光电": "002273.SZ",
            u"高鸿股份": "000851.SZ"
        }

        #初始化股票代码变量
        self.stockName_Val = u"开山股份"
        self.stockCode_Val = self.StNameCodedict[self.stockName_Val]

        self.stockName_CMBO = wx.ComboBox(
            self.ParaPanel,
            -1,
            self.stockName_Val,
            choices=list(self.StNameCodedict.keys()),
            style=wx.CB_READONLY | wx.CB_DROPDOWN)  #股票名称
        stockCode_Text = wx.StaticText(self.ParaPanel, -1, u'股票名称')

        #策略选取
        strate_Text = wx.StaticText(self.ParaPanel, -1, u'策略名称')
        strate_Combo_Val = [u"双趋势融合", u"阿尔法", u"布林带"]
        self.pickstrate_Val = u"双趋势融合"
        self.pickstrate_CMBO = wx.ComboBox(self.ParaPanel,
                                           -1,
                                           self.pickstrate_Val,
                                           choices=strate_Combo_Val,
                                           style=wx.CB_READONLY
                                           | wx.CB_DROPDOWN)  #策略名称

        #日历控件选择数据周期
        self.dpcEndTime = wx.DatePickerCtrl(
            self.ParaPanel,
            -1,
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.DP_ALLOWNONE)  #结束时间
        self.dpcStartTime = wx.DatePickerCtrl(
            self.ParaPanel,
            -1,
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.DP_ALLOWNONE)  #起始时间
        DateTimeNow = wx.DateTime.Now()  #wx.DateTime格式"03/03/18 00:00:00"
        self.dpcEndTime.SetValue(DateTimeNow)
        DateTimeNow.SetYear(DateTimeNow.Year - 1)
        self.dpcStartTime.SetValue(DateTimeNow)
        stockData_Text = wx.StaticText(self.ParaPanel, -1, u'日期(Start-End)')

        #初始化时间变量
        dateVal = self.dpcStartTime.GetValue()
        self.stockSdate_Val = datetime.datetime(dateVal.Year,
                                                dateVal.Month + 1, dateVal.Day)
        dateVal = self.dpcEndTime.GetValue()
        self.stockEdate_Val = datetime.datetime(dateVal.Year,
                                                dateVal.Month + 1, dateVal.Day)

        paraInput_Sizer.Add(stockCode_Text,
                            proportion=0,
                            flag=wx.EXPAND | wx.ALL,
                            border=2)
        paraInput_Sizer.Add(self.stockName_CMBO, 0,
                            wx.EXPAND | wx.ALL | wx.CENTER, 2)
        paraInput_Sizer.Add(stockData_Text,
                            proportion=0,
                            flag=wx.EXPAND | wx.ALL,
                            border=2)
        paraInput_Sizer.Add(self.dpcStartTime, 0,
                            wx.EXPAND | wx.ALL | wx.CENTER, 2)
        paraInput_Sizer.Add(self.dpcEndTime, 0, wx.EXPAND | wx.ALL | wx.CENTER,
                            2)
        paraInput_Sizer.Add(strate_Text, 0, wx.EXPAND | wx.ALL | wx.CENTER, 2)
        paraInput_Sizer.Add(self.pickstrate_CMBO, 0,
                            wx.EXPAND | wx.ALL | wx.CENTER, 2)

        RadioList = ["不显示", "跳空缺口", "金叉/死叉", "N日突破"]
        self.StratInputBox = wx.RadioBox(self.ParaPanel,
                                         -1,
                                         label=u'指标提示',
                                         choices=RadioList,
                                         majorDimension=4,
                                         style=wx.RA_SPECIFY_ROWS)
        self.StratInputBox.Bind(wx.EVT_RADIOBOX, self.OnRadioBox_Indicator)
        #初始化指标变量
        self.IndicatInput_Val = self.StratInputBox.GetStringSelection()

        self.TextAInput = wx.TextCtrl(self.ParaPanel,
                                      -1,
                                      "交易信息提示:",
                                      style=wx.TE_MULTILINE
                                      | wx.TE_READONLY)  #多行|只读

        vboxnetA = wx.BoxSizer(wx.VERTICAL)  #纵向box
        vboxnetA.Add(paraInput_Sizer,
                     proportion=0,
                     flag=wx.EXPAND | wx.BOTTOM,
                     border=2)  #proportion参数控制容器尺寸比例
        vboxnetA.Add(self.StratInputBox,
                     proportion=0,
                     flag=wx.EXPAND | wx.BOTTOM,
                     border=2)
        vboxnetA.Add(self.TextAInput,
                     proportion=1,
                     flag=wx.EXPAND | wx.ALL,
                     border=2)
        self.ParaPanel.SetSizer(vboxnetA)

        #创建Right面板
        self.CtrlPanel = wx.Panel(self, -1)
        #创建FlexGridSizer布局网格
        self.FlexGridSizer = wx.FlexGridSizer(rows=3, cols=1, vgap=3, hgap=3)

        #行情按钮
        self.Firmoffer = wx.Button(self.CtrlPanel, -1, "行情")
        self.Firmoffer.Bind(wx.EVT_BUTTON, self.FirmEvent)  #绑定行情按钮事件
        #选股按钮
        self.Stockpick = wx.Button(self.CtrlPanel, -1, "选股")
        self.Stockpick.Bind(wx.EVT_BUTTON, self.PstockpEvent)  #绑定选股按钮事件
        #回测按钮
        self.Backtrace = wx.Button(self.CtrlPanel, -1, "回测")
        self.Backtrace.Bind(wx.EVT_BUTTON, self.BackEvent)  #绑定回测按钮事件

        #加入Sizer中
        self.FlexGridSizer.Add(self.Firmoffer,
                               proportion=1,
                               border=5,
                               flag=wx.ALL | wx.EXPAND)
        self.FlexGridSizer.Add(self.Stockpick,
                               proportion=1,
                               border=5,
                               flag=wx.ALL | wx.EXPAND)
        self.FlexGridSizer.Add(self.Backtrace,
                               proportion=1,
                               border=5,
                               flag=wx.ALL | wx.EXPAND)
        self.FlexGridSizer.SetFlexibleDirection(wx.BOTH)

        self.CtrlPanel.SetSizer(self.FlexGridSizer)

        self.HBoxPanel = wx.BoxSizer(wx.HORIZONTAL)
        self.HBoxPanel.Add(self.ParaPanel,
                           proportion=1.5,
                           border=2,
                           flag=wx.EXPAND | wx.ALL)
        self.HBoxPanel.Add(self.DispPanel,
                           proportion=8,
                           border=2,
                           flag=wx.EXPAND | wx.ALL)
        self.HBoxPanel.Add(self.CtrlPanel,
                           proportion=1,
                           border=2,
                           flag=wx.EXPAND | wx.ALL)
        self.SetSizer(self.HBoxPanel)
Пример #21
0
    def __init__(self,
                 y_variable,
                 x_variables,
                 group_data,
                 group,
                 options,
                 auto_update_plot=True):
        """
        :param y_variable: dependent variable
        :type y_variable: str
        :param x_variables: independent variables
        :type x_variables: list
        :param group_data: dvhs, table, and stats_data
        :type group_data: dict
        :param options: user options containing visual preferences
        :type options: Options
        """
        wx.Frame.__init__(self,
                          None,
                          title="Multi-Variable Model for %s: Group %s" %
                          (y_variable, group))

        self.y_variable = y_variable
        self.x_variables = x_variables
        self.group_data = group_data
        self.group = group
        self.stats_data = group_data[group]['stats_data']

        set_msw_background_color(
            self)  # If windows, change the background color

        self.options = options

        self.plot = PlotMultiVarRegression(self, options, group)
        if auto_update_plot:
            self.plot.update_plot(y_variable, x_variables, self.stats_data)
            msg = {
                'y_variable': y_variable,
                'x_variables': x_variables,
                'regression': self.plot.reg,
                'group': group
            }
            pub.sendMessage('control_chart_set_model', **msg)

        self.button_back_elimination = wx.Button(self, wx.ID_ANY,
                                                 'Backward Elimination')
        self.button_export = wx.Button(self, wx.ID_ANY, 'Export Plot Data')
        self.button_save_plot = wx.Button(self, wx.ID_ANY, 'Save Plot')
        self.button_save_model = wx.Button(self, wx.ID_ANY, 'Save Model')
        self.button_load_mlr_model = wx.Button(self, wx.ID_ANY, 'Load Model')
        algorithms = [
            'Random Forest', 'Support Vector Machine', 'Decision Tree',
            'Gradient Boosting'
        ]
        self.button = {
            key: wx.Button(self, wx.ID_ANY, key)
            for key in algorithms
        }
        self.radiobox_include_back_elim = wx.RadioBox(
            self, wx.ID_ANY, 'Include all x-variables?', choices=['Yes', 'No'])

        self.__do_bind()
        self.__set_properties()
        self.__do_layout()

        self.ml_frames = []
Пример #22
0
    def __init__(self):
        super().__init__(parent=None, title="Hordes.io bot", size=(420, 350))
        self.browserClass = []
        self.t = []

        #service.py in selenium line 72 has to replace with below code
        #self.process = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=False, creationflags=0x08000000, close_fds=platform.system() != 'Windows')
        self.panel = wx.Panel(self)
        self.botNames = []
        self.Bind(wx.EVT_WINDOW_DESTROY, self.onDestroy)  #destroy the panel

        self.radiobox = wx.RadioBox(self.panel,
                                    label="Browser",
                                    choices=["Chrome", "Firefox"])
        open_browser = wx.Button(self.panel, label="Open Browser")
        self.botlist = wx.ListCtrl(self.panel,
                                   style=wx.LC_REPORT | wx.BORDER_SUNKEN)
        self.botlist.InsertColumn(0, 'Bot name', width=80)
        self.botlist.InsertColumn(1, 'Status', width=80)
        st_info = wx.StaticText(self.panel,
                                label="Revitalize slot 3\nBuffs slot 1 and 2")

        # self.botlist.InsertItem(0,"test")
        # self.botlist.SetItemBackgroundColour(0,wx.RED)

        botlist_refresh_btn = wx.Button(self.panel,
                                        label="Refresh List/\nStop All Bots")
        accept_request_btn = wx.Button(self.panel, label="Accept\nRequest")
        bot_start_btn = wx.Button(self.panel, label="Start")
        bot_stop_btn = wx.Button(self.panel, label="Stop")

        #sizer arrangement
        sizer_browser = wx.BoxSizer(wx.VERTICAL)
        sizer_browser.Add(self.radiobox, flag=wx.LEFT | wx.TOP, border=20)
        sizer_browser.Add(open_browser, flag=wx.LEFT | wx.TOP, border=20)
        sizer_browser.Add(st_info, flag=wx.LEFT | wx.TOP, border=20)

        sizer_refresh = wx.BoxSizer(wx.HORIZONTAL)
        sizer_refresh.Add(botlist_refresh_btn, flag=wx.LEFT, border=20)
        sizer_refresh.Add(accept_request_btn, flag=wx.LEFT, border=20)

        sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
        sizer_buttons.Add(bot_start_btn, flag=wx.LEFT, border=20)
        sizer_buttons.Add(bot_stop_btn, flag=wx.LEFT, border=20)

        sizer_list = wx.BoxSizer(wx.VERTICAL)
        sizer_list.Add(sizer_refresh, flag=wx.TOP, border=20)
        sizer_list.Add(self.botlist, flag=wx.TOP | wx.LEFT, border=20)
        sizer_list.Add(sizer_buttons, flag=wx.TOP, border=20)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(sizer_browser)
        sizer.Add(sizer_list)

        self.panel.SetSizer(sizer)

        botlist_refresh_btn.Bind(wx.EVT_BUTTON, self.botlist_refresh)
        bot_start_btn.Bind(wx.EVT_BUTTON, self.bot_start)
        bot_stop_btn.Bind(wx.EVT_BUTTON, self.bot_stop)
        accept_request_btn.Bind(wx.EVT_BUTTON, self.accept_request)

        open_browser.Bind(wx.EVT_BUTTON, self.login_press)

        self.Show()
Пример #23
0
    def __init__(self, parent, gui_size):
        wx.Panel.__init__(self, parent)
        self.gui_size = gui_size
        self.parent = parent
        h = gui_size[0]
        w = gui_size[1]
        wx.Panel.__init__(self,
                          parent,
                          -1,
                          style=wx.SUNKEN_BORDER,
                          size=(h, w))
        # variable initilization
        self.filelist = []
        self.dir = None
        self.copy = False
        self.cfg = None
        self.loaded = False

        # design the panel
        self.sizer = wx.GridBagSizer(10, 15)

        text1 = wx.StaticText(self,
                              label="DeepLabCut - Step 1. Create New Project")
        self.sizer.Add(text1,
                       pos=(0, 0),
                       flag=wx.TOP | wx.LEFT | wx.BOTTOM,
                       border=15)

        # Add logo of DLC
        icon = wx.StaticBitmap(self, bitmap=wx.Bitmap(logo))
        self.sizer.Add(icon,
                       pos=(0, 7),
                       flag=wx.TOP | wx.RIGHT | wx.ALIGN_RIGHT,
                       border=5)

        line = wx.StaticLine(self)
        self.sizer.Add(line,
                       pos=(1, 0),
                       span=(1, 8),
                       flag=wx.EXPAND | wx.BOTTOM,
                       border=10)

        # Add all the options
        self.proj = wx.RadioBox(
            self,
            label='Please choose an option:',
            choices=['Create new project', 'Load existing project'],
            majorDimension=0,
            style=wx.RA_SPECIFY_COLS)
        self.sizer.Add(self.proj,
                       pos=(2, 0),
                       span=(1, 5),
                       flag=wx.LEFT,
                       border=15)
        self.proj.Bind(wx.EVT_RADIOBOX, self.chooseOption)

        line = wx.StaticLine(self)
        self.sizer.Add(line,
                       pos=(3, 0),
                       span=(1, 8),
                       flag=wx.EXPAND | wx.BOTTOM,
                       border=10)

        self.proj_name = wx.StaticText(self, label="Name of the project:")
        self.sizer.Add(self.proj_name, pos=(4, 0), flag=wx.LEFT, border=15)

        self.proj_name_txt_box = wx.TextCtrl(self)
        self.sizer.Add(self.proj_name_txt_box,
                       pos=(4, 1),
                       span=(1, 2),
                       flag=wx.TOP | wx.EXPAND)

        self.exp = wx.StaticText(self, label="Name of the experimenter:")
        self.sizer.Add(self.exp, pos=(5, 0), flag=wx.LEFT | wx.TOP, border=15)

        self.exp_txt_box = wx.TextCtrl(self)
        self.sizer.Add(self.exp_txt_box,
                       pos=(5, 1),
                       span=(1, 2),
                       flag=wx.TOP | wx.EXPAND,
                       border=5)

        self.vids = wx.StaticText(self, label="Choose the videos:")
        self.sizer.Add(self.vids, pos=(6, 0), flag=wx.TOP | wx.LEFT, border=10)

        self.sel_vids = wx.Button(self, label="Load Videos")
        self.sizer.Add(self.sel_vids,
                       pos=(6, 1),
                       flag=wx.TOP | wx.EXPAND,
                       border=6)
        self.sel_vids.Bind(wx.EVT_BUTTON, self.select_videos)
        #
        sb = wx.StaticBox(self, label="Optional Attributes")
        self.boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)

        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox3 = wx.BoxSizer(wx.HORIZONTAL)

        self.change_workingdir = wx.CheckBox(
            self, label="Select the directory where project will be created")
        hbox2.Add(self.change_workingdir)
        hbox2.AddSpacer(20)
        self.change_workingdir.Bind(wx.EVT_CHECKBOX, self.activate_change_wd)
        self.sel_wd = wx.Button(self, label="Browse")
        self.sel_wd.Enable(False)
        self.sel_wd.Bind(wx.EVT_BUTTON, self.select_working_dir)
        hbox2.Add(self.sel_wd, 0, wx.ALL, -1)
        self.boxsizer.Add(hbox2)

        self.copy_choice = wx.CheckBox(self,
                                       label="Do you want to copy the videos?")
        self.copy_choice.Bind(wx.EVT_CHECKBOX, self.activate_copy_videos)
        hbox3.Add(self.copy_choice)
        hbox3.AddSpacer(155)
        self.yes = wx.RadioButton(self, -1, "No", style=wx.RB_GROUP)
        self.no = wx.RadioButton(self, -1, "Yes")
        self.yes.Enable(False)
        self.no.Enable(False)
        hbox3.Add(self.yes, 0, wx.ALL, -1)
        hbox3.Add(self.no, 0, wx.ALL, -1)
        self.boxsizer.Add(hbox3)
        self.sizer.Add(self.boxsizer,
                       pos=(7, 0),
                       span=(1, 7),
                       flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT,
                       border=10)

        self.cfg_text = wx.StaticText(self, label="Select the config file")
        self.sizer.Add(self.cfg_text,
                       pos=(8, 0),
                       flag=wx.LEFT | wx.EXPAND,
                       border=15)

        if sys.platform == 'darwin':
            self.sel_config = wx.FilePickerCtrl(
                self,
                path="",
                style=wx.FLP_USE_TEXTCTRL,
                message="Choose the config.yaml file",
                wildcard="*.yaml")
        else:
            self.sel_config = wx.FilePickerCtrl(
                self,
                path="",
                style=wx.FLP_USE_TEXTCTRL,
                message="Choose the config.yaml file",
                wildcard="config.yaml")
        self.sizer.Add(self.sel_config,
                       pos=(8, 1),
                       span=(1, 3),
                       flag=wx.TOP | wx.EXPAND,
                       border=5)
        self.sel_config.Bind(wx.EVT_BUTTON, self.create_new_project)
        self.sel_config.SetPath("")
        # Hide the button as this is not the default option
        self.sel_config.Hide()
        self.cfg_text.Hide()

        self.help_button = wx.Button(self, label='Help')
        self.sizer.Add(self.help_button, pos=(9, 0), flag=wx.LEFT, border=10)
        self.help_button.Bind(wx.EVT_BUTTON, self.help_function)

        self.ok = wx.Button(self, label="Ok")
        self.sizer.Add(self.ok, pos=(9, 4))
        self.ok.Bind(wx.EVT_BUTTON, self.create_new_project)

        self.edit_config_file = wx.Button(self, label="Edit config file")
        self.sizer.Add(self.edit_config_file, pos=(9, 2))
        self.edit_config_file.Bind(wx.EVT_BUTTON, self.edit_config)
        self.edit_config_file.Enable(False)

        self.reset = wx.Button(self, label="Reset")
        self.sizer.Add(self.reset,
                       pos=(9, 1),
                       flag=wx.BOTTOM | wx.RIGHT,
                       border=10)
        self.reset.Bind(wx.EVT_BUTTON, self.reset_project)
        self.sizer.AddGrowableCol(2)

        self.SetSizer(self.sizer)
        self.sizer.Fit(self)
Пример #24
0
    def __init__(self):
        wx.Frame.__init__(self,
                          parent=None,
                          title=u'量化软件',
                          size=(1000, 600),
                          style=wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX)
        # 创建显示区面板
        self.DispPanel = Panel(self)

        # 创建参数区面板
        self.ParaPanel = wx.Panel(self, -1)
        paraInput_Box = wx.StaticBox(self.ParaPanel, -1, u'参数输入')
        paraInput_Sizer = wx.StaticBoxSizer(paraInput_Box, wx.VERTICAL)

        Stock_Name_ComboBox = ["浙大网新", "高鸿股份", "天威视讯", "北方导航"]
        stockName_CMBO = wx.ComboBox(self.ParaPanel,
                                     -1,
                                     "浙大网新",
                                     choices=Stock_Name_ComboBox,
                                     style=wx.CB_READONLY
                                     | wx.CB_DROPDOWN)  # 股票名称
        stockCode_Text = wx.StaticText(self.ParaPanel, -1, u'股票名称')

        # 日历控件选择数据周期
        self.dpcEndTime = wx.adv.DatePickerCtrl(self.ParaPanel,
                                                -1,
                                                style=wx.DP_DROPDOWN
                                                | wx.DP_ALLOWNONE)  # 结束时间
        self.dpcStartTime = wx.adv.DatePickerCtrl(
            self.ParaPanel,
            -1,
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.DP_ALLOWNONE)  # 起始时间
        DateTimeNow = wx.DateTime.Now()  # wx.DateTime格式"03/03/18 00:00:00"
        self.dpcEndTime.SetValue(DateTimeNow)
        self.dpcStartTime.SetValue(DateTimeNow)
        stockData_Text = wx.StaticText(self.ParaPanel, -1, u'日期(Start-End)')

        paraInput_Sizer.Add(stockCode_Text,
                            proportion=0,
                            flag=wx.EXPAND | wx.ALL,
                            border=2)
        paraInput_Sizer.Add(stockName_CMBO, 0, wx.EXPAND | wx.ALL | wx.CENTER,
                            2)
        paraInput_Sizer.Add(stockData_Text,
                            proportion=0,
                            flag=wx.EXPAND | wx.ALL,
                            border=2)
        paraInput_Sizer.Add(self.dpcStartTime, 0,
                            wx.EXPAND | wx.ALL | wx.CENTER, 2)
        paraInput_Sizer.Add(self.dpcEndTime, 0, wx.EXPAND | wx.ALL | wx.CENTER,
                            2)

        RadioList = ["跳空缺口", "金叉\死叉", "N日突破", "均线突破"]
        self.StratInputBox = wx.RadioBox(self.ParaPanel,
                                         -1,
                                         label=u'策略选取',
                                         choices=RadioList,
                                         majorDimension=4,
                                         style=wx.RA_SPECIFY_ROWS)

        self.TextAInput = wx.TextCtrl(self.ParaPanel,
                                      -1,
                                      "交易信息提示:",
                                      style=wx.TE_MULTILINE
                                      | wx.TE_READONLY)  # 多行|只读

        vboxnetA = wx.BoxSizer(wx.VERTICAL)  # 纵向box
        vboxnetA.Add(paraInput_Sizer,
                     proportion=0,
                     flag=wx.EXPAND | wx.BOTTOM,
                     border=2)  # proportion参数控制容器尺寸比例
        vboxnetA.Add(self.StratInputBox,
                     proportion=0,
                     flag=wx.EXPAND | wx.BOTTOM,
                     border=2)
        vboxnetA.Add(self.TextAInput,
                     proportion=1,
                     flag=wx.EXPAND | wx.ALL,
                     border=2)
        self.ParaPanel.SetSizer(vboxnetA)

        # 创建Right面板
        self.CtrlPanel = wx.Panel(self, -1)
        # 创建FlexGridSizer布局网格
        self.FlexGridSizer = wx.FlexGridSizer(rows=3, cols=1, vgap=3, hgap=3)

        # 实盘按钮
        self.Firmoffer = wx.Button(self.CtrlPanel, -1, "实盘")
        # 选股按钮
        self.Stockpick = wx.Button(self.CtrlPanel, -1, "选股")
        # 回测按钮
        self.Backtrace = wx.Button(self.CtrlPanel, -1, "回测")

        # 加入Sizer中
        self.FlexGridSizer.Add(self.Firmoffer,
                               proportion=1,
                               border=5,
                               flag=wx.ALL | wx.EXPAND)
        self.FlexGridSizer.Add(self.Stockpick,
                               proportion=1,
                               border=5,
                               flag=wx.ALL | wx.EXPAND)
        self.FlexGridSizer.Add(self.Backtrace,
                               proportion=1,
                               border=5,
                               flag=wx.ALL | wx.EXPAND)
        self.FlexGridSizer.SetFlexibleDirection(wx.BOTH)

        self.CtrlPanel.SetSizer(self.FlexGridSizer)

        self.HBoxPanel = wx.BoxSizer(wx.HORIZONTAL)
        self.HBoxPanel.Add(self.ParaPanel,
                           proportion=1.5,
                           border=2,
                           flag=wx.EXPAND | wx.ALL)
        self.HBoxPanel.Add(self.DispPanel,
                           proportion=8,
                           border=2,
                           flag=wx.EXPAND | wx.ALL)
        self.HBoxPanel.Add(self.CtrlPanel,
                           proportion=1,
                           border=2,
                           flag=wx.EXPAND | wx.ALL)
        self.SetSizer(self.HBoxPanel)
Пример #25
0
    def __init__(self, parent, aPanel, ID=-1, pos=(750, 0), size=(250, 500)):

        wx.Panel.__init__(self, parent, ID, pos, size)
        self.SetBackgroundColour("WHITE")
        self._aPanel = aPanel

        # ---------------------------------------------
        # create Button_Panel on Side_Panel
        self.Button_Panel = wx.Panel(self, -1, pos=(750, 0), size=(250, 100))

        # create ButtonSizer for button_panel
        # buttonSizer = wx.GridSizer(rows=2, cols=2)
        buttonSizer = wx.GridSizer(1, 2, 5, 5)

        # create 4 buttons label, add them to Button_Panel
        # and binding them with corresponding event

        # button = wx.Button(self.Button_Panel, -1, eachLabel)
        bmp = wx.Bitmap("start.jpg", wx.BITMAP_TYPE_PNG)
        button = wx.BitmapButton(self.Button_Panel, -1, bmp, size=(bmp.GetWidth()+10, bmp.GetHeight()+10))
        button.Bind(wx.EVT_BUTTON, self.OnStart)
        buttonSizer.Add(button, 0,  wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 0)

        bmp = wx.Bitmap("stop.jpg", wx.BITMAP_TYPE_PNG)
        button = wx.BitmapButton(self.Button_Panel, -1, bmp, size=(bmp.GetWidth()+10, bmp.GetHeight()+10))
        button.Bind(wx.EVT_BUTTON, self.OnPause)
        buttonSizer.Add(button, 0,  wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 0)

        self.Button_Panel.SetSizer(buttonSizer)

        # self.Button_Panel.Fit()
        # ---------------------------------------------

        # ---------------------------------------------
        # Create ChoiceList_Panel for 2 choice dropdown list
        # Sort_List: provide choice of sorting algorithm
        # Graph_List: provide choice of graph algorithm
        self.ChoiceList_Panel = wx.Panel(self, -1, pos=(750, 150), size=(250, 50))

        SortList = [ '插入排序', '快速排序', '选择排序', '基数排序']

        self.SortChoice = wx.Choice(self.ChoiceList_Panel, -1, choices=SortList)
        self.SortChoice.SetStringSelection('插入排序')
        al_tex = wx.StaticText(self.ChoiceList_Panel, -1, '选择排序算法 :')
        ChoiceSizer = wx.BoxSizer(wx.VERTICAL)
        ChoiceSizer.Add(al_tex, 1, wx.EXPAND | wx.ALL)
        ChoiceSizer.Add(self.SortChoice, 1, wx.EXPAND | wx.ALL)
        self.SortChoice.Bind(wx.EVT_CHOICE, self.sortChange)
        self.ChoiceList_Panel.SetSizer(ChoiceSizer)
        # ---------------------------------------------

        # ---------------------------------------------
        # create Size_Panel
        # Provide a set of size RadioBox
        self.Size_Panel = wx.Panel(self, -1, pos=(750, 300), size=(250, 100))
        SizeList = ['5', '10', '15', '20', '25', '30', '35', '40', '45', '50']
        self.Size_RadioBox = wx.RadioBox(self.Size_Panel, -1, "选择数组长度", wx.DefaultPosition, wx.DefaultSize, SizeList, 5,
                                    wx.RA_SPECIFY_COLS)
        self.Size_RadioBox.Bind(wx.EVT_RADIOBOX, self.sizeChange)
        # SizeSizer = wx.BoxSizer(wx.VERTICAL)
        # SizeSizer.Add(Size_RadioBox, 1, wx.EXPAND | wx.ALL)
        # self.Size_Panel.SetSizer(SizeSizer)

        # ---------------------------------------------

        # ---------------------------------------------
        # create a Speed_Panel
        # Speed_Panel contains a slider used for control the speed of animation
        self.Speed_Panel = wx.Panel(self, -1, pos=(750, 400), size=(250, 100))
        self.Speed_Slider = wx.Slider(self.Speed_Panel, -1, 25, 1, 50, wx.DefaultPosition, (250, -1),
                                 wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS, name="Speed")

        # Speed_Slider.SetTickFreq(5, 1)
        self.Speed_Slider.SetTickFreq(1)
        self.Bind(wx.EVT_SCROLL_THUMBRELEASE, self.sliderSubThumbMoveFunc, self.Speed_Slider)
        Speed_tex = wx.StaticText(self.Speed_Panel, -1, "Change animation's speed")
        Speed_Sizer = wx.BoxSizer(wx.VERTICAL)
        Speed_Sizer.Add(Speed_tex, 0, wx.EXPAND | wx.ALL)
        Speed_Sizer.Add(self.Speed_Slider, 0, wx.EXPAND | wx.ALL)
        self.Speed_Panel.SetSizer(Speed_Sizer)
        # ---------------------------------------------

        Side_PanelSizer = wx.BoxSizer(wx.VERTICAL)
        Side_PanelSizer.Add(self.Button_Panel, 0, wx.EXPAND)
        Side_PanelSizer.Add((-1, 40))
        Side_PanelSizer.Add(self.ChoiceList_Panel, 0, wx.EXPAND)
        Side_PanelSizer.Add((-1, 40))
        Side_PanelSizer.Add(self.Size_Panel, 0, wx.EXPAND)
        Side_PanelSizer.Add((-1, 40))
        Side_PanelSizer.Add(self.Speed_Panel, 0, wx.EXPAND)
        self.SetSizer(Side_PanelSizer)
        self.Center()
Пример #26
0
    def create_gui(self):
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer = wx.FlexGridSizer(7, 2, 0, 0)
        sizer_bitmap1 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_bitmap2 = wx.BoxSizer(wx.HORIZONTAL)

        # tool fields
        self.label = wx.TextCtrl(self, wx.ID_ANY, "")
        self.label_6 = wx.StaticText(self, wx.ID_ANY, "Label:")
        grid_sizer.Add(self.label_6, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        grid_sizer.Add(self.label, 1, wx.EXPAND, 0)

        label_11 = wx.StaticText(self, wx.ID_ANY, "Primary Bitmap:")
        grid_sizer.Add(label_11, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.bitmap1 = wx.TextCtrl(self, wx.ID_ANY, "")
        sizer_bitmap1.Add(self.bitmap1, 1, 0, 0)
        self.bitmap1_button = wx.Button(self, wx.ID_ANY, "...")
        sizer_bitmap1.Add(self.bitmap1_button, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 0)
        grid_sizer.Add(sizer_bitmap1, 1, wx.EXPAND, 0)

        label_12 = wx.StaticText(self, wx.ID_ANY, "Disabled Bitmap:")
        grid_sizer.Add(label_12, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.bitmap2 = wx.TextCtrl(self, wx.ID_ANY, "")
        sizer_bitmap2.Add(self.bitmap2, 1, 0, 0)
        self.bitmap2_button = wx.Button(self, wx.ID_ANY, "...")
        sizer_bitmap2.Add(self.bitmap2_button, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 0)
        grid_sizer.Add(sizer_bitmap2, 1, wx.EXPAND, 0)

        self.label_7 = wx.StaticText(self, wx.ID_ANY, "Event Handler:")
        grid_sizer.Add(self.label_7, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.handler = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer.Add(self.handler, 1, wx.EXPAND, 0)

        self.label_9 = wx.StaticText(self, wx.ID_ANY, "Short Help:")
        grid_sizer.Add(self.label_9, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.short_help = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer.Add(self.short_help, 1, wx.EXPAND, 0)

        self.label_9b = wx.StaticText(self, wx.ID_ANY, "Long Help:")
        grid_sizer.Add(self.label_9b, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.long_help = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer.Add(self.long_help, 1, wx.EXPAND, 0)

        self.label_10 = wx.StaticText(self, wx.ID_ANY, "ID:")
        grid_sizer.Add(self.label_10, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, 4)
        self.id = wx.TextCtrl(self, wx.ID_ANY, "")
        grid_sizer.Add(self.id, 0, 0, 0)
        grid_sizer.AddGrowableCol(1)

        sizer_5.Add(grid_sizer, 2, wx.EXPAND, 0)

        self.type  = wx.RadioBox(self, wx.ID_ANY, "Type", choices=["Normal", "Checkable", "Radio"],
                                       majorDimension=1, style=wx.RA_SPECIFY_COLS)
        sizer_5.Add(self.type, 0, wx.ALL, 4)

        sizer_5.Add((20, 20), 1, 0, 0)

        # editor action buttons
        self.move_up = wx.Button(self, wx.ID_ANY, "Up")
        self.move_down = wx.Button(self, wx.ID_ANY, "Down")
        self.add = wx.Button(self, wx.ID_ANY, "&Add")
        self.remove = wx.Button(self, wx.ID_ANY, "&Remove")
        self.add_sep = wx.Button(self, wx.ID_ANY, "Add &Separator")
        # dialog action buttons; these will be handled, instead of using stock OK/Cancel buttons
        self.ok     = wx.Button(self, wx.ID_ANY, "OK")
        self.cancel = wx.Button(self, wx.ID_ANY, "Cancel")

        sizer_6.Add(self.ok, 0, wx.ALL, 5)
        sizer_6.Add(self.cancel, 0, wx.ALL, 5)
        sizer_5.Add(sizer_6, 0, wx.EXPAND, 0)
        sizer_1.Add(sizer_5, 0, wx.EXPAND, 0)
        sizer_2.Add(self.move_up, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 8)
        sizer_2.Add(self.move_down, 0, wx.BOTTOM | wx.RIGHT | wx.TOP, 8)
        sizer_2.Add((20, 20), 1, 0, 0)
        sizer_2.Add(self.add, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 8)
        sizer_2.Add(self.remove, 0, wx.BOTTOM | wx.TOP, 8)
        sizer_2.Add(self.add_sep, 0, wx.ALL, 8)
        sizer_2.Add((20, 20), 2, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)

        self.items = wx.ListCtrl(self, wx.ID_ANY, style=wx.BORDER_DEFAULT | wx.BORDER_SUNKEN | wx.LC_EDIT_LABELS | wx.LC_REPORT | wx.LC_SINGLE_SEL)
        sizer_1.Add(self.items, 1, wx.EXPAND, 0)

        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()

        self.SetSize( (900, 600) )
Пример #27
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: PyOgg2_MyFrame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((600, 500))
        self.SetTitle(_("mp3 2 ogg"))
        
        # Menu Bar
        self.Mp3_To_Ogg_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_OPEN, _("&Open"), "")
        self.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN)
        wxglade_tmp_menu.Append(wx.ID_EXIT, _("&Quit"), "")
        self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)
        self.Mp3_To_Ogg_menubar.Append(wxglade_tmp_menu, _("&File"))
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_ABOUT, _("&About"), _("About dialog"))
        self.Bind(wx.EVT_MENU, self.OnAboutDialog, id=wx.ID_ABOUT)
        self.Mp3_To_Ogg_menubar.Append(wxglade_tmp_menu, _("&Help"))
        self.SetMenuBar(self.Mp3_To_Ogg_menubar)
        # Menu Bar end
        
        self.Mp3_To_Ogg_statusbar = self.CreateStatusBar(2)
        self.Mp3_To_Ogg_statusbar.SetStatusWidths([-2, -1])
        # statusbar fields
        Mp3_To_Ogg_statusbar_fields = [_("Mp3_To_Ogg_statusbar"), ""]
        for i in range(len(Mp3_To_Ogg_statusbar_fields)):
            self.Mp3_To_Ogg_statusbar.SetStatusText(Mp3_To_Ogg_statusbar_fields[i], i)
        
        # Tool Bar
        self.Mp3_To_Ogg_toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.TB_TEXT)
        self.Mp3_To_Ogg_toolbar.AddLabelTool(wx.ID_OPEN, _("&Open"), wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, _("Open a file"), _("Open a MP3 file to convert into OGG format"))
        self.Bind(wx.EVT_TOOL, self.OnOpen, id=wx.ID_OPEN)
        self.Mp3_To_Ogg_toolbar.Realize()
        self.SetToolBar(self.Mp3_To_Ogg_toolbar)
        # Tool Bar end
        
        sizer_1 = wx.FlexGridSizer(3, 1, 0, 0)
        
        self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=wx.NB_BOTTOM)
        sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)
        
        self.notebook_1_pane_1 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_1, _("Input File"))
        
        _gszr_pane1 = wx.FlexGridSizer(1, 3, 0, 0)
        
        _lbl_input_filename = wx.StaticText(self.notebook_1_pane_1, wx.ID_ANY, _("File name:"))
        _gszr_pane1.Add(_lbl_input_filename, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        
        self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_pane_1, wx.ID_ANY, "")
        self.text_ctrl_1.SetBackgroundColour(wx.NullColour)
        _gszr_pane1.Add(self.text_ctrl_1, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL | wx.EXPAND, 5)
        
        self.button_3 = wx.Button(self.notebook_1_pane_1, wx.ID_OPEN, "")
        _gszr_pane1.Add(self.button_3, 0, wx.ALL, 5)
        
        self.notebook_1_pane_2 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_2, _("Converting Options"))
        
        sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
        
        self.rbx_sampling_rate = wx.RadioBox(self.notebook_1_pane_2, wx.ID_ANY, _("Sampling Rate"), choices=[_("44 kbit"), _("128 kbit")], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.rbx_sampling_rate.SetSelection(0)
        sizer_4.Add(self.rbx_sampling_rate, 1, wx.ALL | wx.EXPAND, 5)
        
        sizer_3 = wx.StaticBoxSizer(wx.StaticBox(self.notebook_1_pane_2, wx.ID_ANY, _("Misc")), wx.HORIZONTAL)
        sizer_4.Add(sizer_3, 1, wx.ALL | wx.EXPAND, 5)
        
        self.cbx_love = wx.CheckBox(self.notebook_1_pane_2, wx.ID_ANY, _(u"♥ Love this song"))
        self.cbx_love.SetToolTipString(_(u"Yes!\nWe ♥ it!"))
        self.cbx_love.SetValue(1)
        sizer_3.Add(self.cbx_love, 0, wx.ALL | wx.SHAPED, 5)
        
        self.notebook_1_pane_3 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_3, _("Converting Progress"))
        
        _szr_pane3 = wx.BoxSizer(wx.HORIZONTAL)
        
        self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_pane_3, wx.ID_ANY, "", style=wx.TE_MULTILINE)
        _szr_pane3.Add(self.text_ctrl_2, 1, wx.ALL | wx.EXPAND, 5)
        
        self.notebook_1_pane_4 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_4, _("Output File"))
        
        _gszr_pane4 = wx.FlexGridSizer(2, 3, 0, 0)
        
        self._lbl_output_filename = wx.StaticText(self.notebook_1_pane_4, wx.ID_ANY, _("File name:"))
        _gszr_pane4.Add(self._lbl_output_filename, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        
        self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_pane_4, wx.ID_ANY, "")
        self.text_ctrl_3.SetToolTipString(_("File name of the output file\nAn existing file will be overwritten without futher information!"))
        _gszr_pane4.Add(self.text_ctrl_3, 0, wx.ALL | wx.EXPAND, 5)
        
        self.button_4 = wx.Button(self.notebook_1_pane_4, wx.ID_OPEN, "")
        _gszr_pane4.Add(self.button_4, 0, wx.ALL, 5)
        
        _gszr_pane4.Add((20, 20), 0, 0, 0)
        
        self.checkbox_1 = wx.CheckBox(self.notebook_1_pane_4, wx.ID_ANY, _("Overwrite existing file"))
        self.checkbox_1.SetToolTipString(_("Overwrite an existing file"))
        self.checkbox_1.SetValue(1)
        _gszr_pane4.Add(self.checkbox_1, 0, wx.ALL | wx.EXPAND, 5)
        
        _gszr_pane4.Add((20, 20), 0, 0, 0)
        
        self.notebook_1_pane_5 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_5, _("Some Text"))
        
        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
        
        self.label_1 = wx.StaticText(self.notebook_1_pane_5, wx.ID_ANY, _("Please check the format of those lines manually:\n\nSingle line without any special characters.\n\na line break between new and line: new\nline\na tab character between new and line: new\tline\ntwo backslash characters: \\\\ \nthree backslash characters: \\\\\\ \na double quote: \"\nan escaped new line sequence: \\n"))
        sizer_5.Add(self.label_1, 1, wx.ALL | wx.EXPAND, 5)
        
        self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
        sizer_1.Add(self.static_line_1, 0, wx.ALL | wx.EXPAND, 5)
        
        sizer_2 = wx.FlexGridSizer(1, 3, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.ALIGN_RIGHT, 0)
        
        self.button_5 = wx.Button(self, wx.ID_CLOSE, "")
        sizer_2.Add(self.button_5, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        
        self.button_2 = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_TOP)
        sizer_2.Add(self.button_2, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        
        self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP)
        sizer_2.Add(self.button_1, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        
        self.notebook_1_pane_5.SetSizer(sizer_5)
        
        _gszr_pane4.AddGrowableCol(1)
        self.notebook_1_pane_4.SetSizer(_gszr_pane4)
        
        self.notebook_1_pane_3.SetSizer(_szr_pane3)
        
        self.notebook_1_pane_2.SetSizer(sizer_4)
        
        _gszr_pane1.AddGrowableCol(1)
        self.notebook_1_pane_1.SetSizer(_gszr_pane1)
        
        sizer_1.AddGrowableRow(0)
        sizer_1.AddGrowableCol(0)
        self.SetSizer(sizer_1)
        sizer_1.SetSizeHints(self)
        
        self.Layout()
        self.Centre()

        self.Bind(wx.EVT_BUTTON, self.startConverting, self.button_1)
Пример #28
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.Size(508, 919),
                          style=wx.TAB_TRAVERSAL)

        bSizer19 = wx.BoxSizer(wx.VERTICAL)

        self.m_staticText85 = wx.StaticText(self, wx.ID_ANY,
                                            u"Run Selected Processes",
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)
        self.m_staticText85.Wrap(-1)
        self.m_staticText85.SetFont(
            wx.Font(14, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL, False, "Arial"))

        bSizer19.Add(self.m_staticText85, 0, wx.ALL, 5)

        self.m_staticline7 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition,
                                           wx.DefaultSize, wx.LI_HORIZONTAL)
        bSizer19.Add(self.m_staticline7, 0, wx.EXPAND | wx.ALL, 5)

        bSizer20 = wx.BoxSizer(wx.HORIZONTAL)

        m_checkListProcessChoices = [u"None", u"QSM", u"Atlas"]
        self.m_checkListProcess = wx.RadioBox(
            self, wx.ID_ANY, u"Processing options", wx.DefaultPosition,
            wx.DefaultSize, m_checkListProcessChoices, 1, wx.RA_SPECIFY_COLS)
        self.m_checkListProcess.SetSelection(0)
        bSizer20.Add(self.m_checkListProcess, 0, wx.ALL, 5)

        bSizer15 = wx.BoxSizer(wx.VERTICAL)

        self.m_stTitle = wx.StaticText(self, wx.ID_ANY, u"TITLE",
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_stTitle.Wrap(-1)
        self.m_stTitle.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DECORATIVE,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False,
                    wx.EmptyString))

        bSizer15.Add(self.m_stTitle, 0, wx.ALL, 5)

        self.m_stDescription = wx.StaticText(
            self, wx.ID_ANY, u"Process Description", wx.DefaultPosition,
            wx.Size(-1, 80), 0 | wx.FULL_REPAINT_ON_RESIZE | wx.VSCROLL)
        self.m_stDescription.Wrap(-1)
        self.m_stDescription.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT,
                    wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False,
                    wx.EmptyString))

        bSizer15.Add(self.m_stDescription, 0, wx.ALL | wx.EXPAND, 5)

        bSizer16 = wx.BoxSizer(wx.HORIZONTAL)

        self.m_btnRunProcess = wx.Button(self, wx.ID_ANY, u"Run",
                                         wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_btnRunProcess.SetForegroundColour(wx.Colour(255, 255, 0))
        self.m_btnRunProcess.SetBackgroundColour(wx.Colour(0, 128, 0))

        bSizer16.Add(self.m_btnRunProcess, 0, wx.ALL, 5)

        self.m_btnStopProcess = wx.Button(self, wx.ID_ANY, u"Stop",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.m_btnStopProcess.SetForegroundColour(wx.Colour(255, 0, 0))
        self.m_btnStopProcess.Enable(False)

        bSizer16.Add(self.m_btnStopProcess, 0, wx.ALL, 5)

        bSizer15.Add(bSizer16, 1, wx.ALIGN_BOTTOM, 5)

        bSizer20.Add(bSizer15, 1, wx.EXPAND, 5)

        bSizer19.Add(bSizer20, 1, wx.EXPAND, 5)

        bSizer21 = wx.BoxSizer(wx.VERTICAL)

        self.m_dataViewListCtrlRunning = wx.dataview.DataViewListCtrl(
            self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
            wx.dataview.DV_ROW_LINES | wx.FULL_REPAINT_ON_RESIZE | wx.VSCROLL)
        self.m_dataViewListCtrlRunning.SetMinSize(wx.Size(-1, 400))

        self.m_dataViewListColumnProcess = self.m_dataViewListCtrlRunning.AppendTextColumn(
            u"Process")
        self.m_dataViewListColumnSeries = self.m_dataViewListCtrlRunning.AppendTextColumn(
            u"Series ID")
        self.m_dataViewListColumnStatus = self.m_dataViewListCtrlRunning.AppendProgressColumn(
            u"Status")
        self.m_dataViewListColumnOutput = self.m_dataViewListCtrlRunning.AppendTextColumn(
            u"Output")
        bSizer21.Add(self.m_dataViewListCtrlRunning, 0, wx.ALL | wx.EXPAND, 5)

        bSizer19.Add(bSizer21, 1, wx.EXPAND, 5)

        self.m_stOutputlog = wx.StaticText(
            self, wx.ID_ANY, u"View processing output in log file",
            wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_stOutputlog.Wrap(-1)
        bSizer19.Add(self.m_stOutputlog, 0, wx.ALL, 5)

        self.SetSizer(bSizer19)
        self.Layout()

        # Connect Events
        self.m_checkListProcess.Bind(wx.EVT_RADIOBOX, self.OnShowDescription)
        self.m_btnRunProcess.Bind(wx.EVT_BUTTON, self.OnRunScripts)
        self.m_btnStopProcess.Bind(wx.EVT_BUTTON, self.OnCancelScripts)
Пример #29
0
    def _doLayout(self, modeChoices, showDbInfo=False):
        """Do dialog layout"""

        self.pagesizer = wx.BoxSizer(wx.VERTICAL)

        # dbInfo
        if showDbInfo:
            databasebox = StaticBox(parent=self.panel,
                                    id=wx.ID_ANY,
                                    label=" %s " % _("Database connection"))
            databaseboxsizer = wx.StaticBoxSizer(databasebox, wx.VERTICAL)
            databaseboxsizer.Add(CreateDbInfoDesc(self.panel,
                                                  self.dbInfo,
                                                  layer=self.layer),
                                 proportion=1,
                                 flag=wx.EXPAND | wx.ALL,
                                 border=3)

        #
        # text areas
        #
        # sql box
        sqlbox = StaticBox(parent=self.panel,
                           id=wx.ID_ANY,
                           label=" %s " % _("Query"))
        sqlboxsizer = wx.StaticBoxSizer(sqlbox, wx.VERTICAL)

        self.text_sql = TextCtrl(parent=self.panel,
                                 id=wx.ID_ANY,
                                 value='',
                                 size=(-1, 50),
                                 style=wx.TE_MULTILINE)

        self.text_sql.SetInsertionPointEnd()
        wx.CallAfter(self.text_sql.SetFocus)

        sqlboxsizer.Add(self.text_sql, flag=wx.EXPAND)

        #
        # buttons
        #
        self.btn_clear = Button(parent=self.panel, id=wx.ID_CLEAR)
        self.btn_clear.SetToolTip(_("Set SQL statement to default"))
        self.btn_apply = Button(parent=self.panel, id=wx.ID_APPLY)
        self.btn_apply.SetToolTip(_("Apply SQL statement"))
        self.btn_close = Button(parent=self.panel, id=wx.ID_CLOSE)
        self.btn_close.SetToolTip(_("Close the dialog"))

        self.btn_logic = {
            'is': [
                '=',
            ],
            'isnot': [
                '!=',
            ],
            'like': [
                'LIKE',
            ],
            'gt': [
                '>',
            ],
            'ge': [
                '>=',
            ],
            'lt': [
                '<',
            ],
            'le': [
                '<=',
            ],
            'or': [
                'OR',
            ],
            'not': [
                'NOT',
            ],
            'and': [
                'AND',
            ],
            'brac': [
                '()',
            ],
            'prc': [
                '%',
            ]
        }

        self.btn_logicpanel = wx.Panel(parent=self.panel, id=wx.ID_ANY)
        for key, value in six.iteritems(self.btn_logic):
            btn = Button(parent=self.btn_logicpanel,
                         id=wx.ID_ANY,
                         label=value[0])
            self.btn_logic[key].append(btn.GetId())

        self.buttonsizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=5)
        self.buttonsizer.Add(self.btn_clear)
        self.buttonsizer.Add(self.btn_apply)
        self.buttonsizer.Add(self.btn_close)

        btn_logicsizer = wx.GridBagSizer(5, 5)
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['is'][1]),
                           pos=(0, 0))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['isnot'][1]),
                           pos=(1, 0))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['like'][1]),
                           pos=(2, 0))

        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['gt'][1]),
                           pos=(0, 1))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['ge'][1]),
                           pos=(1, 1))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['or'][1]),
                           pos=(2, 1))

        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['lt'][1]),
                           pos=(0, 2))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['le'][1]),
                           pos=(1, 2))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['not'][1]),
                           pos=(2, 2))

        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['brac'][1]),
                           pos=(0, 3))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['prc'][1]),
                           pos=(1, 3))
        btn_logicsizer.Add(self.FindWindowById(self.btn_logic['and'][1]),
                           pos=(2, 3))

        self.btn_logicpanel.SetSizer(btn_logicsizer)

        #
        # list boxes (columns, values)
        #
        self.hsizer = wx.BoxSizer(wx.HORIZONTAL)

        columnsbox = StaticBox(parent=self.panel,
                               id=wx.ID_ANY,
                               label=" %s " % _("Columns"))
        columnsizer = wx.StaticBoxSizer(columnsbox, wx.VERTICAL)
        self.list_columns = wx.ListBox(parent=self.panel,
                                       id=wx.ID_ANY,
                                       choices=self.dbInfo.GetColumns(
                                           self.tablename),
                                       style=wx.LB_MULTIPLE)
        columnsizer.Add(self.list_columns, proportion=1, flag=wx.EXPAND)

        if modeChoices:
            modesizer = wx.BoxSizer(wx.VERTICAL)

            self.mode = wx.RadioBox(parent=self.panel,
                                    id=wx.ID_ANY,
                                    label=" %s " % _("Interactive insertion"),
                                    choices=modeChoices,
                                    style=wx.RA_SPECIFY_COLS,
                                    majorDimension=1)

            self.mode.SetSelection(1)  # default 'values'
            modesizer.Add(self.mode,
                          proportion=1,
                          flag=wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND,
                          border=5)

        # self.list_columns.SetMinSize((-1,130))
        # self.list_values.SetMinSize((-1,100))

        self.valuespanel = wx.Panel(parent=self.panel, id=wx.ID_ANY)
        valuesbox = StaticBox(parent=self.valuespanel,
                              id=wx.ID_ANY,
                              label=" %s " % _("Values"))
        valuesizer = wx.StaticBoxSizer(valuesbox, wx.VERTICAL)
        self.list_values = wx.ListBox(parent=self.valuespanel,
                                      id=wx.ID_ANY,
                                      choices=self.colvalues,
                                      style=wx.LB_MULTIPLE)
        valuesizer.Add(self.list_values, proportion=1, flag=wx.EXPAND)
        self.valuespanel.SetSizer(valuesizer)

        self.btn_unique = Button(parent=self.valuespanel,
                                 id=wx.ID_ANY,
                                 label=_("Get all values"))
        self.btn_unique.Enable(False)
        self.btn_uniquesample = Button(parent=self.valuespanel,
                                       id=wx.ID_ANY,
                                       label=_("Get sample"))
        self.btn_uniquesample.SetToolTip(
            _("Get first 256 unique values as sample"))
        self.btn_uniquesample.Enable(False)

        buttonsizer3 = wx.BoxSizer(wx.HORIZONTAL)
        buttonsizer3.Add(self.btn_uniquesample,
                         proportion=0,
                         flag=wx.ALIGN_CENTER_HORIZONTAL | wx.RIGHT,
                         border=5)
        buttonsizer3.Add(self.btn_unique,
                         proportion=0,
                         flag=wx.ALIGN_CENTER_HORIZONTAL)

        valuesizer.Add(buttonsizer3, proportion=0, flag=wx.TOP, border=5)

        # go to
        gotosizer = wx.BoxSizer(wx.HORIZONTAL)
        self.goto = TextCtrl(parent=self.valuespanel,
                             id=wx.ID_ANY,
                             style=wx.TE_PROCESS_ENTER)
        gotosizer.Add(StaticText(parent=self.valuespanel,
                                 id=wx.ID_ANY,
                                 label=_("Go to:")),
                      proportion=0,
                      flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT,
                      border=5)
        gotosizer.Add(self.goto, proportion=1, flag=wx.EXPAND)
        valuesizer.Add(gotosizer,
                       proportion=0,
                       flag=wx.ALL | wx.EXPAND,
                       border=5)

        self.hsizer.Add(columnsizer, proportion=1, flag=wx.EXPAND)
        self.hsizer.Add(self.valuespanel, proportion=1, flag=wx.EXPAND)

        self.close_onapply = wx.CheckBox(parent=self.panel,
                                         id=wx.ID_ANY,
                                         label=_("Close dialog on apply"))
        self.close_onapply.SetValue(True)

        if showDbInfo:
            self.pagesizer.Add(databaseboxsizer,
                               flag=wx.ALL | wx.EXPAND,
                               border=5)
        if modeChoices:
            self.pagesizer.Add(modesizer,
                               proportion=0,
                               flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
                               border=5)
        self.pagesizer.Add(self.hsizer,
                           proportion=1,
                           flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
                           border=5)
        # self.pagesizer.Add(self.btn_uniqe,0,wx.ALIGN_LEFT|wx.TOP,border=5)
        # self.pagesizer.Add(self.btn_uniqesample,0,wx.ALIGN_LEFT|wx.TOP,border=5)
        self.pagesizer.Add(self.btn_logicpanel,
                           proportion=0,
                           flag=wx.ALIGN_CENTER_HORIZONTAL)
        self.pagesizer.Add(sqlboxsizer,
                           proportion=0,
                           flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
                           border=5)
        self.pagesizer.Add(self.buttonsizer,
                           proportion=0,
                           flag=wx.ALIGN_RIGHT | wx.ALL,
                           border=5)
        self.pagesizer.Add(self.close_onapply,
                           proportion=0,
                           flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
                           border=5)

        #
        # bindings
        #
        if modeChoices:
            self.mode.Bind(wx.EVT_RADIOBOX, self.OnMode)
        # self.text_sql.Bind(wx.EVT_ACTIVATE, self.OnTextSqlActivate)TODO

        self.btn_unique.Bind(wx.EVT_BUTTON, self.OnUniqueValues)
        self.btn_uniquesample.Bind(wx.EVT_BUTTON, self.OnSampleValues)

        for key, value in six.iteritems(self.btn_logic):
            self.FindWindowById(value[1]).Bind(wx.EVT_BUTTON, self.OnAddMark)

        self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose)
        self.btn_clear.Bind(wx.EVT_BUTTON, self.OnClear)
        self.btn_apply.Bind(wx.EVT_BUTTON, self.OnApply)

        self.list_columns.Bind(wx.EVT_LISTBOX, self.OnAddColumn)
        self.list_values.Bind(wx.EVT_LISTBOX, self.OnAddValue)
        self.goto.Bind(wx.EVT_TEXT, self.OnGoTo)
        self.goto.Bind(wx.EVT_TEXT_ENTER, self.OnAddValue)
Пример #30
0
    def __init__(self, parent, gui_size, cfg):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)

        # variable initilization
        self.method = "automatic"
        self.config = cfg
        # design the panel
        sizer = wx.GridBagSizer(5, 5)

        text = wx.StaticText(self, label="DeepLabCut - Step 2. Extract Frames")
        sizer.Add(text,
                  pos=(0, 0),
                  flag=wx.TOP | wx.LEFT | wx.BOTTOM,
                  border=15)
        # Add logo of DLC
        icon = wx.StaticBitmap(self, bitmap=wx.Bitmap(logo))
        sizer.Add(icon,
                  pos=(0, 4),
                  flag=wx.TOP | wx.RIGHT | wx.ALIGN_RIGHT,
                  border=5)

        line1 = wx.StaticLine(self)
        sizer.Add(line1,
                  pos=(1, 0),
                  span=(1, 5),
                  flag=wx.EXPAND | wx.BOTTOM,
                  border=10)

        self.cfg_text = wx.StaticText(self, label="Select the config file")
        sizer.Add(self.cfg_text, pos=(2, 0), flag=wx.TOP | wx.LEFT, border=5)

        if sys.platform == 'darwin':
            self.sel_config = wx.FilePickerCtrl(
                self,
                path="",
                style=wx.FLP_USE_TEXTCTRL,
                message="Choose the config.yaml file",
                wildcard="*.yaml")
        else:
            self.sel_config = wx.FilePickerCtrl(
                self,
                path="",
                style=wx.FLP_USE_TEXTCTRL,
                message="Choose the config.yaml file",
                wildcard="config.yaml")
        # self.sel_config = wx.FilePickerCtrl(self, path="",style=wx.FLP_USE_TEXTCTRL,message="Choose the config.yaml file", wildcard="config.yaml")
        sizer.Add(self.sel_config,
                  pos=(2, 1),
                  span=(1, 3),
                  flag=wx.TOP | wx.EXPAND,
                  border=5)
        self.sel_config.SetPath(self.config)
        self.sel_config.Bind(wx.EVT_FILEPICKER_CHANGED, self.select_config)

        sb = wx.StaticBox(self, label="Optional Attributes")
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)

        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox3 = wx.BoxSizer(wx.HORIZONTAL)

        self.method_choice = wx.RadioBox(self,
                                         label='Choose the extraction method',
                                         choices=['automatic', 'manual'],
                                         majorDimension=1,
                                         style=wx.RA_SPECIFY_COLS)
        self.method_choice.Bind(wx.EVT_RADIOBOX, self.select_extract_method)
        hbox1.Add(self.method_choice, 5, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        self.crop_choice = wx.RadioBox(
            self,
            label='Want to crop the frames?',
            choices=['False', 'True (read from config file)', 'GUI'],
            majorDimension=1,
            style=wx.RA_SPECIFY_COLS)
        hbox1.Add(self.crop_choice, 5, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        self.feedback_choice = wx.RadioBox(self,
                                           label='Need user feedback?',
                                           choices=['No', 'Yes'],
                                           majorDimension=1,
                                           style=wx.RA_SPECIFY_COLS)
        hbox1.Add(self.feedback_choice, 5, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        self.opencv_choice = wx.RadioBox(self,
                                         label='Want to use openCV?',
                                         choices=['No', 'Yes'],
                                         majorDimension=1,
                                         style=wx.RA_SPECIFY_COLS)
        self.opencv_choice.SetSelection(1)
        hbox1.Add(self.opencv_choice, 5, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        algo_text = wx.StaticBox(self, label="Select the algorithm")
        algoboxsizer = wx.StaticBoxSizer(algo_text, wx.VERTICAL)
        self.algo_choice = wx.ComboBox(self, style=wx.CB_READONLY)
        options = ['kmeans', 'uniform']
        self.algo_choice.Set(options)
        self.algo_choice.SetValue('kmeans')
        algoboxsizer.Add(self.algo_choice, 20, wx.EXPAND | wx.TOP | wx.BOTTOM,
                         10)

        cluster_step_text = wx.StaticBox(self,
                                         label="Specify the cluster step")
        cluster_stepboxsizer = wx.StaticBoxSizer(cluster_step_text,
                                                 wx.VERTICAL)
        self.cluster_step = wx.SpinCtrl(self, value='1')
        cluster_stepboxsizer.Add(self.cluster_step, 20,
                                 wx.EXPAND | wx.TOP | wx.BOTTOM, 10)

        slider_width_text = wx.StaticBox(self,
                                         label="Specify the GUI slider width")
        slider_widthboxsizer = wx.StaticBoxSizer(slider_width_text,
                                                 wx.VERTICAL)
        self.slider_width = wx.SpinCtrl(self, value='25')
        slider_widthboxsizer.Add(self.slider_width, 20,
                                 wx.EXPAND | wx.TOP | wx.BOTTOM, 10)

        hbox3.Add(algoboxsizer, 10, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
        hbox3.Add(cluster_stepboxsizer, 10, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
        hbox3.Add(slider_widthboxsizer, 10, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        boxsizer.Add(hbox1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10)
        boxsizer.Add(hbox2, 5, wx.EXPAND | wx.TOP | wx.BOTTOM, 10)
        boxsizer.Add(hbox3, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10)

        sizer.Add(boxsizer,
                  pos=(3, 0),
                  span=(1, 5),
                  flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT,
                  border=10)

        self.help_button = wx.Button(self, label='Help')
        sizer.Add(self.help_button, pos=(4, 0), flag=wx.LEFT, border=10)
        self.help_button.Bind(wx.EVT_BUTTON, self.help_function)

        self.ok = wx.Button(self, label="Ok")
        sizer.Add(self.ok, pos=(4, 4))
        self.ok.Bind(wx.EVT_BUTTON, self.extract_frames)

        self.reset = wx.Button(self, label="Reset")
        sizer.Add(self.reset,
                  pos=(4, 1),
                  span=(1, 1),
                  flag=wx.BOTTOM | wx.RIGHT,
                  border=10)
        self.reset.Bind(wx.EVT_BUTTON, self.reset_extract_frames)

        sizer.AddGrowableCol(2)

        self.SetSizer(sizer)
        sizer.Fit(self)