Пример #1
0
    def onButton(self, event):
        obj = event.GetEventObject()
        named = obj.GetName()
        debug = False

        active_list = [
            ('Name', 'invMaint_priceSchemes_listctrl_name_txtctrl'),
            ('Schemed', 'invMaint_priceSchemes_listctrl_scheme_txtctrl'),
            ('Reduce By', 'invMaint_priceSchemes_listctrl_reduceby_numctrl')
        ]

        print("Button : ", named)
        if 'add' in named:
            listctrl = wx.FindWindowByName('invMaint_priceSchemes_listctrl')
            line = listctrl.GetItemCount()

            for label, name in active_list:
                print("Name : ", name)
                ctrl = wx.FindWindowByName(name)
                value = ctrl.GetValue()
                if not value:
                    ctrl.SetBackgroundColour('RED')
                    return

                print("LIST CTRL : ", listctrl.GetName())
                if '_name_' in name:
                    listctrl.InsertItem(line, value)
                    print("Set {0} : {1} on Line {2}".format(
                        'Name', value, line))

                if '_scheme_' in name:
                    listctrl.SetItem(line, 1, str(value))
                    print("Set {0} : {1} on Line {2}".format(
                        'Scheme', value, line))

                if '_reduceby_' in name:
                    listctrl.SetItem(line, 2, str(value))
                    print("Set {0} : {1} on Line {2}".format(
                        'Reduce By', value, line))

        if 'clear' in named:
            for label, name in active_list:
                print("Clear Name : ", name)
                wx.FindWindowByName(name).ClearCtrl()

        if 'delete' in named:
            lc_name = 'invMaint_priceSchemes_listctrl'
            print("Listctrl Name : ", lc_name)
            listctrl = wx.FindWindowByName(lc_name)
            line = listctrl.GetFirstSelected()
            print("item : ", listctrl)

            named = listctrl.GetItemText(line)
            print("Named : ", named)

            query = 'DELETE FROM item_pricing_schemes WHERE name=(?)'
            data = (named, )
            returnd = SQConnect(query, data).ONE()

            listctrl.DeleteItem(line)
Пример #2
0
    def onButtonPressDown(self, event, objName=''):
        """ wx.Butotn was pressed.
        
        Args:
            event (wx.Event)
            objName (str, optional): objName to emulate the button press
              of the button with the given name.
        
        Returns:
            None
        """
        if DEBUG: print("CamRecFrame.onButtonPressDown()")

        if objName == '':
            obj = event.GetEventObject()
            objName = obj.GetName()
        else:
            obj = wx.FindWindowByName(objName, self.panel["ui"])
        if not obj.IsEnabled(): return

        if objName in ["addCam_btn", "remCam_btn"]:
            cho = wx.FindWindowByName("camIdx_cho", self.panel["ui"])
            choStr = cho.GetString(cho.GetSelection()).strip()
            if choStr != "":
                ci = int(choStr)
                flag = objName[:3]  # add or rem
                self.addRemCam(ci, flag)  # toggle selected cam

        elif objName == "remAllCam_btn":
            self.addRemCam(-1, "remAll")  # remove all added cams

        elif objName == "toggleRec_btn":
            self.toggleRec()  # toggle recording
Пример #3
0
 def OnModeChoice(self, evt):
     modectrl = wx.FindWindowByName('mode')
     polarctrl = wx.FindWindowByName('polar')
     if modectrl.GetStringSelection() == 'dic':
         polarctrl.Enable(True)
     else:
         polarctrl.Enable(False)
Пример #4
0
    def ListBoxOnAddButton(self, event):

        obj = event.GetEventObject()
        print(f'OBJ : {obj}')

        addbutton_name = obj.GetName()
        print(f'addbutton name : {obj.GetName()}')
        listbox_name = re.sub('_addbutton', '', addbutton_name)
        tc_name = re.sub('_addbutton', '_txtctrl', addbutton_name)
        lc_txtctrl = wx.FindWindowByName(tc_name)
        if not lc_txtctrl.GetValue():
            return
        print(f'List Box Name : {listbox_name}')
        listbox = wx.FindWindowByName(listbox_name)
        num_altlookups = listbox.GetCount()

        tobe_searched = lc_txtctrl.GetValue()
        has_found = listbox.FindString(tobe_searched)
        addbutton = wx.FindWindowByName(addbutton_name)
        if has_found != -1:

            foundIndex = has_found
            listbox.EnsureVisible(foundIndex)
            addbutton.SetBackgroundColour('Red')
            lc_txtctrl.Clear()
            lc_txtctrl.SetFocus()
        else:

            addbutton.SetBackgroundColour('Green')
            listbox.Append(lc_txtctrl.GetValue().upper())
            lc_txtctrl.Clear()
            lc_txtctrl.SetFocus()

        allstrings = listbox.GetStrings()
Пример #5
0
    def OnRightUp(self, event):
        """
            Generate and open menu on right click
        """
        if self.Selection >= 0:
            # populate the popup menu with actions
            self.menu.RemoveAllItems()

            acct = self.active[self.Selection]
            if hasattr(getattr(acct, 'menu_actions', None), '__call__'):
                acct.menu_actions(self.menu)
            elif isinstance(acct, EmailAccount):
                #HAX: an ugly hack until Email-specific actions are removed from EmailAccount.
                actions.menu(wx.FindWindowByName('Buddy List'),
                             acct,
                             menu=self.menu,
                             search_bases=False,
                             cls=EmailAccount)
            else:
                actions.menu(wx.FindWindowByName('Buddy List'),
                             acct,
                             menu=self.menu)

            self.menu.AddSep()

            #            if self.prefkey is not None:
            #                unlockitem = self.menu.AddCheckItem(_('Allow Rearrange'), callback = self.ToggleOrderLock)
            #                unlockitem.Check(self.unlocked)

            self.menu.PopupMenu()
Пример #6
0
    def updateFileList(self):
        """ This function is called when selected folders or target file 
        name or extension has changed. 
        This function updates file list, which will be renamed.

        Args: None

        Returns: None
        """
        if DEBUG: print("ImgProcsFrame.updateFileList()")

        fL = []
        tcFN = wx.FindWindowByName("targetFN_txt", self.panel["ui"])
        fileForm = "%s"%(tcFN.GetValue()) 
        ### update self.fileList
        for dp in self.selectedFolders:
            p = path.join(dp, fileForm)
            for fp in glob(p):
                bn = path.basename(fp)
                ext = bn.split(".")[-1]
                if ext in self.extList:
                    fL.append(fp)
        self.fileList = fL

        ### update ListCtrl to show files to be processed 
        lc = wx.FindWindowByName("selFile_lst", self.panel["ui"])
        lc.DeleteAllItems() # delete the current contents
        for i, fp in enumerate(self.fileList):
            lc.Append([fp])
        self.showImgProcRslt()
Пример #7
0
    def __init__(self, root: "wx.App", state: State) -> None:
        self._root = root
        self._state = state

        self.grid = wx.FindWindowByName("ss_grid")
        self.grid.CreateGrid(0, 0)
        self.grid.EnableEditing(False)
        self.grid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell)

        for _, widget in self._get_radio_buttons():
            widget.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton)

        wx_bind("ss_load", wx.EVT_BUTTON, self.OnLoadButton)
        wx_bind(
            "ss_add_verification",
            wx.EVT_BUTTON,
            lambda event: self.OnVerificationButton(event, True),
        )
        wx_bind(
            "ss_remove_verification",
            wx.EVT_BUTTON,
            lambda event: self.OnVerificationButton(event, False),
        )

        root.undo_buttons.append(wx.FindWindowByName("ss_button_undo"))
        root.redo_buttons.append(wx.FindWindowByName("ss_button_redo"))

        self.refresh_ui()
Пример #8
0
 def onShowScript(self, event):
     if DEBUGGING: print('EGUIFrame.onShowScript()')
     event.Skip()
     self.flag_script_visible = not self.flag_script_visible
     btn = event.GetEventObject()
     if self.flag_script_visible == True:
         self.sPanel.stc.Show()  # hide script
         for w in self.sPanel.widgets[0]:
             w.Show()  # hide script related widgets
         set_img_for_btn(
             path.join(self.e_gui_path, "input/img_script_hide.png"), btn)
     else:
         self.sPanel.stc.Hide()  # show script
         for w in self.sPanel.widgets[0]:
             w.Hide()  # show script related widgets
         set_img_for_btn(
             path.join(self.e_gui_path, "input/img_script_show.png"), btn)
     ### show/hide marker buttons in main panel
     for item in self.mPanel.items.keys():
         if item in self.iPanel.choice_items:
             valWid = wx.FindWindowByName(item + "_cho", self.mPanel)
         else:
             valWid = wx.FindWindowByName(item + "_txt", self.mPanel)
         if valWid == None or valWid.IsShown() == False: continue
         btn = wx.FindWindowByName(item + "_marker_btn", self.mPanel)
         if self.flag_script_visible == True: btn.Show()
         else: btn.Hide()
     self.mPanel.gbs.Layout()
     self.sPanel.gbs.Layout()
Пример #9
0
    def testCanAddRecurringTransaction(self):
        model = self.Model
        a = model.CreateAccount("testCanAddRecurringTransaction")

        self.assertEquals(len(a.Transactions), 0)
        self.assertEquals(a.Balance, 0)

        self.NewTransactionCtrl.amountCtrl.Value = "12.34"
        self.NewTransactionCtrl.recursCheck.Value = True

        # Test the default of this field, and that it doesn't end.
        summaryText = wx.FindWindowByName("RecurringSummaryText")
        self.assertTrue(summaryText.Label.startswith("Weekly on "))
        self.assertFalse("until" in summaryText.Label)

        # Now set an end date and make sure that gets displayed.
        rb = wx.FindWindowByName("EndsSometimeRadio")
        rb.Value = True
        # Setting the value programmatically doesn't trigger an event, so do so.
        wx.FindWindowByName("RecurringPanel").Update()
        self.assertTrue("until" in summaryText.Label)

        self.NewTransactionCtrl.onNewTransaction()

        self.assertEquals(len(a.Transactions), 0)
        self.assertEquals(a.Balance, 0)
        self.assertEquals(len(a.RecurringTransactions), 1)
Пример #10
0
    def showHideProcParamWidgets(self, pn=''):
        """ Show wxPython widgets of parameters for a processing (pn),
        or hide them.

        Args:
            pn (str): Processing name

        Returns:
            None
        """
        if DEBUG: print("ImgProcsFrame.showHideProcParamWidgets()")

        flag = [] # list of True/False values to indicate show/hide widgets
        if pn != '':
        # processing name given, meaning to show the relevant parameters
            flag.append(True) # for showing processing name staticText
            nP = len(self.ipParams[pn]) # number of parameters
            for i in range(self.mNumParam):
                if i >= nP: flag.append(False)
                else: flag.append(True)
            flag.append(True) # for showing update button
        else:
        # no processing name given, meaning to hide widgets 
            flag.append(True) # for showing processing name staticText
            for i in range(self.mNumParam):
                flag.append(False) # for hiding parameter widgets
            flag.append(False) # for hiding update button

        ### show/hide widgets
        idx = 0
        w = wx.FindWindowByName("processName_sTxt", self.panel["ui"])
        if flag[idx]:
            w.SetLabel(pn)
            w.Show() # show process name
        else:
            w.Hide()
        for i in range(self.mNumParam):
            idx += 1
            w = wx.FindWindowByName("param%i_sTxt"%(i), self.panel["ui"])
            if flag[idx]: 
                w.Show() # show parameter description
                w.SetLabel(self.ipParamDesc[pn][i])
            else:
                w.Hide()
            w = wx.FindWindowByName("param%i_txt"%(i), self.panel["ui"])
            if flag[idx]:
                w.Show() # show parameter value
                w.SetValue(str(self.ipParamVal[pn][i]))
            else:
                w.Hide()
        idx += 1
        w = wx.FindWindowByName("updateParam_btn", self.panel["ui"])
        if flag[idx]: w.Show() # show update button
        else: w.Hide() # hide update button

        ### refresh gbs and panel
        self.gbs["ui"].Layout()
        self.panel["ui"].Layout()
        self.panel["ui"].SetupScrolling()
Пример #11
0
    def toggleCamThread(self, ci):
        """ Start/Stop a cam thread
        
        Args:
            ci (int): Index of cam to start
        
        Returns:
            None
        """
        if DEBUG: print("CamRecFrame.startCamThread()")

        if self.th[ci] == -1:  # thread is not running
            ### update output format for Cam recording
            cho = wx.FindWindowByName("outputFormat_cho", self.panel["ui"])
            outputFormat = cho.GetString(cho.GetSelection())  # video or image
            self.cams[ci].outputFormat = outputFormat
            if outputFormat == "video":
                ### update FPS limit for Cam recording
                w = wx.FindWindowByName("videoFPSlimit_spin", self.panel["ui"])
                fpsLimit = str2num(w.GetValue(), 'float')
                if fpsLimit != None: self.cams[ci].fpsLimit = fpsLimit
            elif outputFormat == "image":
                ### update snapshot interval for Cam recording
                w = wx.FindWindowByName("ssIntv_spin", self.panel["ui"])
                ssIntv = str2num(w.GetValue(), 'float')
                if ssIntv != None: self.cams[ci].ssIntv = ssIntv
            ### start Cam thread
            args = (
                self.q2m,
                self.q2t[ci],
                self.recFolder,
            )
            self.th[ci] = Thread(target=self.cams[ci].run, args=args)
            self.th[ci].start()
            ### start timer to check q2m
            ###   (queued message from the running thread)
            if "chkQ2M" in self.timer.keys() and \
              self.timer["chkQ2M"].IsRunning() == False:
                self.timer["chkQ2M"].Start(50)
            else:
                self.timer["chkQ2M"] = wx.Timer(self)
                self.Bind(wx.EVT_TIMER, self.chkQ2M, self.timer["chkQ2M"])
                self.timer["chkQ2M"].Start(self.dispImgRefreshIntv)
            # log message
            log = "%s, Cam-%.2i thread started\n" % (get_time_stamp(), ci)

        else:
            ### stop Cam thread
            self.q2t[ci].put("quit", True, None)  # send message to quit thread
            self.th[ci].join()
            self.th[ci] = -1
            ### if no cam thread is running, stop chkQ2M timer as well.
            if self.th == [-1] * len(self.th):
                self.timer["chkQ2M"].Stop()
            # log message
            log = "%s, Cam-%.2i thread stopped\n" % (get_time_stamp(), ci)
        writeFile(self.logFile, log)
Пример #12
0
 def GetParams(self):
     params = {}
     params['smoothing'] = self.smoothchoice.GetStringSelection()
     for param in self.numparams:
         ctrl = wx.FindWindowByName(param)
         params[param] = float(ctrl.GetValue())
     for param in self.boolparams:
         params[param] = wx.FindWindowByName(param).GetValue()
     return params
Пример #13
0
    def OnButton1(self, evt):
        print("CWD: %s\n" % os.getcwd())

        dlg = wx.FileDialog(self,
                            message="Choose a file",
                            defaultDir=os.getcwd(),
                            defaultFile="",
                            wildcard=wildcard,
                            style=wx.FD_OPEN | wx.FD_MULTIPLE
                            | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST
                            | wx.FD_PREVIEW)

        # Show the dialog and retrieve the user response. If it is the OK response,
        # process the data.
        if dlg.ShowModal() == wx.ID_OK:
            # This returns a Python list of files that were selected.
            paths = dlg.GetPaths()

            print('You selected %d files:' % len(paths))

            for path in paths:
                file_path = path

        # Compare this with the debug above; did we change working dirs?
        path_ = os.getcwd()

        # Destroy the dialog. Don't do this until you are done with it!
        # BAD things can happen otherwise!
        dlg.Destroy()

        # image = wx.Image(file_path, wx.BITMAP_TYPE_JPEG)
        # temp = image.ConvertToBitmap()
        # self.bmp = wx.StaticBitmap(parent=self.m_panel2, bitmap=temp, size=(300, 300))
        bmp = wx.Bitmap(
            'C:/Users/zx/Desktop/ClothingRetrieval/picture/null.jpg')
        # 图片
        name = "Bitmap"
        RecipesBitmap = wx.FindWindowByName(name=name)
        RecipesBitmap.SetBitmap(bmp)
        bmp = wx.Bitmap(file_path)
        # 图片
        name = "Bitmap"
        RecipesBitmap = wx.FindWindowByName(name=name)
        RecipesBitmap.SetBitmap(bmp)

        img = cv2.imread(file_path)
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        gray = cv2.resize(gray, (220, 220))
        gray = gray.reshape(-1, 1, 220, 220) / 255.
        answer = int(np.argmax(model.predict(gray), axis=1))
        print("预测值  :", cloth_dict[int(np.argmax(model.predict(gray),
                                                 axis=1))])

        self.RecipesSizer.changeSizer(answer, path_)
        # self.picSizer = self.RecipesSizer.getSizer()
        print(answer)
Пример #14
0
 def _func(item):
     # show/hide item title and its help button
     sTxt = wx.FindWindowByName("%s_sTxt" % (item), self)
     helpBtn = wx.FindWindowByName("%s_help_btn" % (item), self)
     if self.flag_bItemsList1_shown == False:
         sTxt.Show()
         helpBtn.Show()
     elif self.flag_bItemsList1_shown == True:
         sTxt.Hide()
         helpBtn.Hide()
Пример #15
0
    def selectTemplate(self, event):
        """ Selecting a folder which contains sample WAV files 
        to form a template WAV data.

        Args: event (wx.Event)

        Returns: None
        """ 
        if DEBUG: print("PyListenerFrame.selectTemplate()")
        if (type(event) == str and event == 'File'):
            dlg = wx.FileDialog(
                                self, 
                                "Select a template wave file", 
                                CWD, 
                                wildcard="(*.wav)|*.wav"
                               )
            listenFlag = 'templateFile'
        else:
            msg = "Select a folder which contains WAV files for template."
            msg += " All WAV files in the selected folder will be considered"
            msg += " as template."
            dlg = wx.DirDialog(self, msg, CWD) 
            listenFlag = 'templateFolder'
        if dlg.ShowModal() == wx.ID_OK:
            if self.pl.isListening == True:  # if mic. stream is open, 
                self.onBPButtonPress('startStopListening')  # close it.
            fPath = dlg.GetPath()
            self.pl.templFP = fPath
            # get analyzed parameters of template file(s).
            __, __, params = self.pl.listen(flag=listenFlag, wavFP=fPath) 
            ### update template folder name
            txt = wx.FindWindowByName( "comp_fName", self.panel["ip_spT"] )
            txt.SetValue(path.basename(fPath))
            ### update comparison param. values
            pList = self.pl.compParamList
            for p in pList:
                bName = "comp_" + p
                if not p in self.pl.indCPL:
                    txt = wx.FindWindowByName( bName, self.panel["ip_spT"] )
                    value = params[p]
                    if type(value) == 'str': value = "%.3f"%(value)
                    if type(value) == 'list': value = str(value)
                    txt.SetValue("%s"%(value))
                txt = wx.FindWindowByName( bName+"_min", self.panel["ip_spT"] )
                value = params[p+"_min"]
                if type(value) == 'str': value = "%.3f"%(value)
                if type(value) == 'list': value = str(value)
                txt.SetValue("%s"%(value))
                txt = wx.FindWindowByName( bName+"_max", self.panel["ip_spT"] )
                value = params[p+"_max"]
                if type(value) == 'str': value = "%.3f"%(value)
                if type(value) == 'list': value = str(value)
                txt.SetValue("%s"%(value))

        self.panel['spT'].Refresh()  # draw spectrogram 
Пример #16
0
    def setUp(self):
        testbase.TestCaseHandlingConfigBase.setUp(self)
        if not hasattr(wx, "appInst"):
            wx.appInst = main.init(":memory:", welcome=False)

        self.App = wx.appInst
        self.Frame = self.App.TopWindow
        self.Model = self.Frame.Panel.bankController.Model
        self.OLV = wx.FindWindowByName("TransactionOLV")
        self.AccountListCtrl = wx.FindWindowByName("AccountListCtrl")
        self.NewTransactionCtrl = wx.FindWindowByName("NewTransactionCtrl")
Пример #17
0
    def addRemCam(self, ci=-1, flag="add"):
        """ Add/Remove a cam
        
        Args:
            ci (int): Index of cam
            flag (str): Flag for turning on (add) or off (rem)
        
        Returns:
            None
        """
        if DEBUG: print("CamRecFrame.toggleCam()")

        if flag == "add" and ci != -1:
            if self.th[ci] == -1:
                self.toggleCamThread(ci)
                self.oCIdx.append(ci)
        elif flag == "rem" and ci != -1:
            if self.th[ci] != -1:
                self.toggleCamThread(ci)
                self.oCIdx.remove(ci)
        elif flag == "remAll":
            for ci in list(self.oCIdx):
                if self.th[ci] != -1:
                    self.toggleCamThread(ci)
                    self.oCIdx.remove(ci)
        self.enableDisableCamWidgets(flag=flag[:3])

        ### show opened cam index and its recording type
        sTxt = wx.FindWindowByName("openCI_sTxt", self.panel["ui"])
        s = []
        for ci in self.oCIdx:
            of = self.cams[ci].outputFormat[0]  # first letter of output format
            if of == "v":  # output format is video
                w = wx.FindWindowByName("videoFPSlimit_spin", self.panel["ui"])
            elif of == "i":  # output format is image
                w = wx.FindWindowByName("ssIntv_spin", self.panel["ui"])
            of += "/%s" % (w.GetValue())
            s.append("%i[%s]" % (ci, of))
        sTxt.SetLabel(str(s).strip("[]").replace("'", ""))

        pSz = self.pi["rp"]["sz"]  # panel size
        # number of frames on one side
        self.nCOnSide = int(np.ceil(np.sqrt(len(self.oCIdx))))
        ### update display frame size for each cam
        if self.nCOnSide == 0:
            w, h = pSz
        else:
            w = int(pSz[0] / self.nCOnSide)
            h = int(w / 1.333)
        self.dispCSz = [w, h]
        ### init display image with black
        self.dispArr[:, :, :] = 0
        img = wx.Image(self.dispCSz[0], self.dispCSz[1])
        self.disp_sBmp.SetBitmap(img.ConvertToBitmap())
Пример #18
0
    def onButtonPressDown(self, event, objName=''):
        """ wx.Butotn was pressed.

        Args:
            event (wx.Event)
            objName (str, optional): objName to emulate the button press
              of the button with the given name.

        Returns: 
            None
        """
        if DEBUG: print("ImgProcsFrame.onButtonPressDown()")

        if objName == '':
            obj = event.GetEventObject()
            objName = obj.GetName()
        else:
            obj = wx.FindWindowByName(objName, self.panel["ui"])
        if not obj.IsEnabled(): return

        if objName == "selFolders_btn":
            self.selectFolders() 

        elif objName == "run_btn":
            self.showHideProcParamWidgets() # hide all parameter widgets
            self.runImgProc() # run image processing 

        elif objName == "clearProc_btn":
            self.showHideProcParamWidgets() # hide all parameter widgets
            lc = wx.FindWindowByName("proc_lst", self.panel["ui"])
            idx = lc.GetFirstSelected()
            itemTxt = lc.GetItemText(idx) 
            lc.DeleteItem(idx) # delete selected item
            self.procList.remove(itemTxt) # remove from planned processing list

        elif objName == "clearAllProc_btn":
            self.showHideProcParamWidgets() # hide all parameter widgets
            ### remove all planned processes 
            lc = wx.FindWindowByName("proc_lst", self.panel["ui"])
            lc.DeleteAllItems() # delete all items
            self.procList = [] # delete all planned processing list

        elif objName == "moveProcUp_btn":
            lc = wx.FindWindowByName("proc_lst", self.panel["ui"])
            self.moveItemInLC(lc, 'up') 
        
        elif objName == "moveProcDown_btn":
            lc = wx.FindWindowByName("proc_lst", self.panel["ui"])
            self.moveItemInLC(lc, 'down') 

        elif objName == "updateParam_btn":
            self.updateParamValues() # update parameters
            self.showHideProcParamWidgets() # hide all parameter widgets
Пример #19
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        box = wx.StaticBox(self, -1, 'Image Config')
        boxsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        cropbox = wx.StaticBox(self, -1, 'Croppings')
        cropboxsizer = wx.StaticBoxSizer(cropbox, wx.VERTICAL)
        cropsizer = wx.FlexGridSizer(cols=2)

        for index, side in enumerate(SIDES):
            title = wx.StaticText(self, -1, side)
            cropping = wx.TextCtrl(self,
                                   -1,
                                   '0',
                                   style=wx.TE_PROCESS_ENTER,
                                   name=side + 'crop',
                                   validator=widgets.NumValidator('int',
                                                                  min=0))
            self.Bind(wx.EVT_TEXT_ENTER, parent.OnConfigImage, cropping)
            cropsizer.Add(title, 1,
                          wx.GROW | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
            cropsizer.Add(cropping, 1, wx.ALIGN_LEFT | wx.GROW)
        cropsizer.AddGrowableCol(1)
        cropboxsizer.Add(cropsizer, 1, wx.GROW)
        boxsizer.Add(cropboxsizer, 1, wx.GROW)

        sizer = wx.FlexGridSizer(cols=2)
        for value in self.ChoiceParams():
            paramname, longName, choices = value
            label = wx.StaticText(self, -1, paramname)
            chbox = wx.Choice(self, -1, choices=choices, name=paramname)
            sizer.Add(label, 1,
                      wx.GROW | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
            sizer.Add(chbox, 1, wx.GROW | wx.ALIGN_LEFT)
        sizer.AddGrowableCol(0)
        sizer.AddGrowableCol(1)
        boxsizer.Add(sizer, 0, wx.GROW)
        self.Bind(wx.EVT_CHOICE, parent.OnConfigImage,
                  wx.FindWindowByName('orient'))
        self.Bind(wx.EVT_CHOICE, self.OnModeChoice,
                  wx.FindWindowByName('mode'))

        for boolparam in self.BoolParams():
            cb = wx.CheckBox(self,
                             -1,
                             boolparam + "?",
                             style=wx.ALIGN_LEFT,
                             name=boolparam)
            boxsizer.Add(cb, 0, wx.ALIGN_LEFT)

        self.SetSizer(boxsizer)
        self.Fit()
        for child in self.GetChildren():
            child.Enable(False)
Пример #20
0
    def ListBoxSelectItem(self, event):
        obj = event.GetEventObject()
        obj_name = obj.GetName()
        tc_name = re.sub('_listbox', '_listbox_txtctrl', obj_name)
        addbutton_name = re.sub('_listbox', '_listbox_addbutton', obj_name)
        rembutton_name = re.sub('_listbox', '_listbox_rembutton', obj_name)
        listbox_name = obj_name

        lc_txtctrl = wx.FindWindowByName(tc_name)
        addbutton = wx.FindWindowByName(addbutton_name)
        rembutton = wx.FindWindowByName(rembutton_name)
        listbox = wx.FindWindowByName(listbox_name)
        selection = listbox.GetStringSelection()
        wx.FindWindowByName(tc_name).SetCtrl(selection)
Пример #21
0
    def selectFolders(self):
        """ Select folders 

        Args: None

        Returns: None
        """
        if DEBUG: print("ImgProcsFrame.selectFolders()")
        
        dlg = MDD.MultiDirDialog(
                     None, 
                     title="Select folders with images to process.",
                     defaultPath=CWD,
                     agwStyle=MDD.DD_MULTIPLE|MDD.DD_DIR_MUST_EXIST,
                                ) # select multiple folders
        if dlg.ShowModal() == wx.ID_OK:
            self.selectedFolders = dlg.GetPaths()
            if sys.platform == 'darwin': # OS X
                ### remove root string
                for i, fp in enumerate(self.selectedFolders):
                    si = fp.find("/")
                    if si != -1:
                        fp = fp[fp.index("/"):] # cut off the fisrt directory name,
                          # MultiDirDialog returns with disk name as root
                          # Instead of '/tmp', 
                          # it returns 'Macintosh HD/tmp'.
                    self.selectedFolders[i] = fp 

            ### include sub folder, 
            ###   if "including sub folder" option was checked.
            sfChk = wx.FindWindowByName("subFolders_chk", self.panel["ui"])
            if sfChk.GetValue() == True:
                ### update folder lists
                folderL = copy(self.selectedFolders)
                self.selectedFolders = []
                for dp in folderL:
                # go through selected folders
                    self.selectedFolders.append(dp) # append the selected folder
                    self.addFolders(dp) # add sub-folders in this folder

            ### show folder list in UI
            selDir_txt = wx.FindWindowByName("selDir_txt", 
                                             self.panel["ui"])
            _txt = str(self.selectedFolders)
            _txt = _txt.strip("[]").replace("'","").replace(", ","\n\n")
            selDir_txt.SetValue(_txt) # show list of selected folders

            self.updateFileList() # update files to be renamed
        dlg.Destroy()
Пример #22
0
    def on_close(self, evt=None):
        # Classifier needs to be told to close so it can clean up it's threads
        classifier = wx.FindWindowById(ID_CLASSIFIER) or wx.FindWindowByName(
            'Classifier')
        if classifier and classifier.Close() == False:
            return

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

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

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

        self.Destroy()
Пример #23
0
 def OnSave(self):
     print("Pricing Schemes")
     listctrl = wx.FindWindowByName('invMaint_priceSchemes_listctrl')
     count = listctrl.GetItemCount()
     for idx in range(count):
         name_scheme = listctrl.GetItemText(idx)
         print("Get Item {0} : {1}".format(listctrl.GetItem(idx),
                                           name_scheme))
         queryWhere = 'name=(?)'
         queryData = (name_scheme, )
         countd = QueryOps().QueryCheck('item_pricing_schemes', queryWhere,
                                        queryData)
         print("Countd : ", countd)
         if countd == 0:
             name = listctrl.GetItem(idx, 0).GetText().strip()
             schemeList = listctrl.GetItem(idx, 1).GetText().strip()
             reduceby = listctrl.GetItem(idx, 2).GetText()
             print("Name : {0}, Scheme : {1}, ReduceBy : {2}".format(
                 name, schemeList, reduceby))
             query = 'INSERT INTO item_pricing_schemes (name,scheme_list,reduce_by) VALUES ((?),(?),(?))'
             data = (
                 name,
                 schemeList,
                 reduceby,
             )
             returnd = SQConnect(query, data).ONE()
Пример #24
0
    def onAisleNum(self, event):
        obj = event.GetEventObject()
        name = obj.GetName()
        value = wx.FindWindowByName(name).GetValue()

        sectionNums = wx.FindWindowByName('genOptions_sectionNums_combobox')
        locations = wx.FindWindowByName('genOptions_extraPlaces_combobox')
        if value != '0':
            sectionNums.Enable()
            locations.Disable()
            locations.SetValue('')

        else:
            locations.Enable()
            sectionNums.Disable()
            sectionNums.SetValue('')
Пример #25
0
    def OnComputeEnd(self, delayedResult):
        """
        Callback function that plots the results of a phase reconstruction and
        phase inversion operation.
        """

        # The delayedResult object is not used to get the results because
        # currently no results are passed back; instead plots are generated.

        # Stop and hide the progress gauge.
        self.pan2_gauge.Stop()
        self.pan2_gauge.Show(False)
        self.pan2.Layout()

        # Make the plots visible.
        pylab.draw()

        # Write the total execution and plotting time to the status bar.
        secs = time.time() - self.t0
        self.sbi.write(2, "    %g secs" %(secs))

        # Show widgets previously hidden at the start of this computation.
        self.btn_compute.Enable(True)
        frame = wx.FindWindowByName("AppFrame")
        frame.load_demo_dataset_1_item.Enable(True)
        frame.load_demo_dataset_2_item.Enable(True)
Пример #26
0
    def OnSelChanged(self, event):
        model = self.tree.GetItemData(event.GetItem())
        if not model or not model[0]:
            return
        data = model[0]

        notebook = self.right
        page = wx.FindWindowByName(str(id(model[2])), notebook)
        pageIndex = notebook.GetPageIndex(page)
        if not page and pageIndex < 0:
            if isinstance(data, Curriculum):
                curr = CurriculumPanel(notebook, model)
                notebook.AddPage(curr, data.title, True, 1)
            elif isinstance(data, Lesson):
                lesson = LessonPanel(notebook, model)
                notebook.AddPage(lesson, data.title, True, 2)
            elif isinstance(data, LessonExercise):
                le = LessonExercisePanel(notebook, model)
                notebook.AddPage(le, data.title, True, 5)
            elif isinstance(data, Exercise):
                exercise = ExercisePanel(notebook, model)
                notebook.AddPage(exercise, data.title, True, 3)
            elif isinstance(data, Illustration):
                illustration = IllustrationPanel(notebook, model)
                notebook.AddPage(illustration, data.title, True, 4)
        else:
            self.right.SetSelection(pageIndex)
Пример #27
0
 def OpenInJessica(self, uiObjectOrRenderObject):
     try:
         import wx
         tree = wx.FindWindowByName('TreeView2')
         tree.AddUITree(uiObjectOrRenderObject.name, uiObjectOrRenderObject)
     except ImportError:
         pass
Пример #28
0
Файл: lbc.py Проект: njsch/PyLBC
def GetDefaultParent():
	app = None
	if not wx.GetApp(): app = App()
	parent = wx.GetActiveWindow()
	if not parent: parent = wx.FindWindowByName('desktop') # ctypes.windll.USER32.GetDesktopWindow()
	if app: app.Destroy()
	return parent
Пример #29
0
 def _OpenInJessica(self, obj):
     try:
         import wx
         tree = wx.FindWindowByName('TreeView2')
         tree.AddUITree(obj.name, obj)
     except ImportError:
         pass
Пример #30
0
 def set_latency(self, latency):
     evt = wx.CommandEvent(wx.wxEVT_COMMAND_SLIDER_UPDATED)
     parent = wx.FindWindowByName('main_frame')
     value = latency * 1000
     parent.chart_panel.options.time_slider.SetValue(value)
     evt.SetId(parent.chart_panel.options.time_slider.GetId())
     wx.PostEvent(parent, evt)