Exemplo n.º 1
0
    def __init__(self,
                 parent,
                 label='',
                 clipStart=0,
                 clipDuration=0,
                 showModally=True):
        """ Initialize the Progress Dialog """

        # There's a bug.  I think it's an interaction between OS X 10.7.5 and earlier (but not 10.8.4), wxPython (version
        # unknown, but I've seen it in 2.8.12.1, 2.9.4.0, and a pre-release build of 2.9.5.0), and the build process.
        # Basically, if you open a wxFileDialog object, something bad happens with wxLocale such that subsequent calls
        # to wxProcess don't encode unicode file names correctly, so FFMpeg fails.  Only OS X 10.7.5, only when Transana
        # has been built (not running through the interpreter), only following the opening of a wxFileDialog, and only
        # with filenames with accented characters or characters from non-English languages.

        # The resolution to this bug is to reset the Locale here, based on Transana's current wxLocale setting in the
        # menuWindow object.
        self.locale = wx.Locale(TransanaGlobal.menuWindow.locale.Language)

        # Remember the Parent
        self.parent = parent
        # Remember whether we're MODAL or ALLOWING MULTIPLE THREADS
        self.showModally = showModally
        # Remember the start time and duration, if they are passed in.
        self.clipStart = clipStart
        self.clipDuration = clipDuration

        # Define the process variable
        self.process = None
        # Initialize a list to collect error messages
        self.errorMessages = []

        # Encode the prompt
        prompt = unicode(_('Media File Conversion Progress'), 'utf8')
        # Define the Dialog Box.  wx.STAY_ON_TOP required because this dialog can't be modal, but shouldn't be hidden or worked behind.
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           prompt,
                           size=(400, 160),
                           style=wx.CAPTION | wx.STAY_ON_TOP)

        # To look right, the Mac needs the Small Window Variant.
        if "__WXMAC__" in wx.PlatformInfo:
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        # Create the main Sizer, which is Vertical
        sizer = wx.BoxSizer(wx.VERTICAL)
        # Create a horizontal sizer for the text below the progress bar.
        timeSizer = wx.BoxSizer(wx.HORIZONTAL)

        # For now, place an empty StaticText label on the Dialog
        self.lbl = wx.StaticText(self, -1, label)
        sizer.Add(self.lbl, 0, wx.ALIGN_LEFT | wx.ALL, 10)

        # Progress Bar
        self.progressBar = wx.Gauge(self,
                                    -1,
                                    100,
                                    style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
        sizer.Add(self.progressBar, 0,
                  wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        # Seconds Processed label
        # Encode the prompt
        prompt = unicode(_("%d:%02d:%02d of %d:%02d:%02d processed"), 'utf8')
        self.lblTime = wx.StaticText(self,
                                     -1,
                                     prompt % (0, 0, 0, 0, 0, 0),
                                     style=wx.ST_NO_AUTORESIZE)
        timeSizer.Add(self.lblTime, 0,
                      wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 10)
        timeSizer.Add((0, 5), 1, wx.EXPAND)

        # Percent Processed label
        self.lblPercent = wx.StaticText(self,
                                        -1,
                                        "%3d %%" % 0,
                                        style=wx.ST_NO_AUTORESIZE
                                        | wx.ALIGN_RIGHT)
        timeSizer.Add(self.lblPercent, 0,
                      wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT | wx.TOP, 10)
        sizer.Add(timeSizer, 1, wx.EXPAND)

        elapsedSizer = wx.BoxSizer(wx.HORIZONTAL)

        # Time Elapsed label
        # Encode the prompt
        prompt = unicode(_("%s elapsed"), 'utf8')
        self.lblElapsed = wx.StaticText(self,
                                        -1,
                                        prompt % '0:00:00',
                                        style=wx.ST_NO_AUTORESIZE
                                        | wx.ALIGN_LEFT)
        elapsedSizer.Add(self.lblElapsed, 0, wx.ALIGN_LEFT | wx.LEFT, 10)
        elapsedSizer.Add((0, 5), 1, wx.EXPAND)

        # Time Remaining label
        # Encode the prompt
        prompt = unicode(_("%s remaining"), 'utf8')
        self.lblRemaining = wx.StaticText(self,
                                          -1,
                                          prompt % '0:00:00',
                                          style=wx.ST_NO_AUTORESIZE
                                          | wx.ALIGN_RIGHT)
        elapsedSizer.Add(self.lblRemaining, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10)
        sizer.Add(elapsedSizer, 1, wx.EXPAND | wx.BOTTOM, 4)

        # Cancel button
        # Encode the prompt
        prompt = unicode(_("Cancel"), 'utf8')
        self.btnCancel = wx.Button(self, -1, prompt)
        sizer.Add(self.btnCancel, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        self.btnCancel.Bind(wx.EVT_BUTTON, self.OnInterrupt)

        self.SetSizer(sizer)
        # Set this as the minimum size for the form.
        sizer.SetMinSize(wx.Size(350, 160))
        # Call Layout to "place" the widgits
        self.Layout()
        self.SetAutoLayout(True)
        self.Fit()

        # Create a Timer that will check for progress feedback
        self.timer = wx.Timer()
        self.timer.Bind(wx.EVT_TIMER, self.OnTimer)

        TransanaGlobal.CenterOnPrimary(self)
Exemplo n.º 2
0
    def __init__(self, parent, id):
        super(ComponentTypeView, self).__init__(parent, id, wx.DefaultPosition)

        vbox = wx.BoxSizer(wx.VERTICAL)
        self.parent = parent
        self._current_type = None
        self.grid = wx.GridSizer(0, 2, 3, 3)

        self.lookup_button = wx.Button(self, 310, 'Part Lookup')
        self.save_button = wx.Button(self, 311, 'Save Part to Datastore')

        self.qty_text = wx.TextCtrl(self, 301, '', style=wx.TE_READONLY)
        self.refs_text = wx.TextCtrl(self, 302, '', style=wx.TE_READONLY)
        self.fp_text = wx.TextCtrl(self, 303, '', style=wx.TE_READONLY)
        self.value_text = wx.TextCtrl(self, 304, '')
        self.ds_text = wx.TextCtrl(self, 305, '')
        self.mfr_text = wx.TextCtrl(self, 306, '')
        self.mpn_text = wx.TextCtrl(self, 307, '')
        self.spr_text = wx.TextCtrl(self, 308, '')
        self.spn_text = wx.TextCtrl(self, 309, '')

        # Bind the save and lookup component buttons
        self.save_button.Bind(wx.EVT_BUTTON,
                              self.on_save_to_datastore,
                              id=wx.ID_ANY)
        self.lookup_button.Bind(wx.EVT_BUTTON,
                                self.on_lookup_component,
                                id=wx.ID_ANY)

        # Set the background color of the read only controls to
        # slightly darker to differentiate them
        for ctrl in (self.qty_text, self.refs_text, self.fp_text):
            ctrl.SetBackgroundColour(wx.ColourDatabase().Find('Light Grey'))

        self._populate_grid()

        # Create fooprint selector box
        fpbox = wx.BoxSizer(wx.VERTICAL)

        fp_label = wx.StaticText(self,
                                 -1,
                                 'Footprints',
                                 style=wx.ALIGN_CENTER_HORIZONTAL)
        self.fp_list = wx.ListBox(self, 330, style=wx.LB_SINGLE)

        fpbox.Add(fp_label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND)
        fpbox.Add(self.fp_list, 1, wx.EXPAND)

        self.fp_list.Bind(wx.EVT_LISTBOX, self.on_fp_list, id=wx.ID_ANY)

        # Create Component selector box
        compbox = wx.BoxSizer(wx.VERTICAL)

        comp_label = wx.StaticText(self,
                                   -1,
                                   'Components',
                                   style=wx.ALIGN_CENTER_HORIZONTAL)
        self.comp_list = wx.ListBox(self, 331, style=wx.LB_SINGLE)

        compbox.Add(comp_label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND)
        compbox.Add(self.comp_list, 1, wx.EXPAND)
        self.comp_list.Bind(wx.EVT_LISTBOX, self.on_comp_list, id=wx.ID_ANY)

        # Lay out the fpbox and compbox side by side
        selbox = wx.BoxSizer(wx.HORIZONTAL)

        selbox.Add(fpbox, 1, wx.EXPAND)
        selbox.Add(compbox, 1, wx.EXPAND)

        # Perform final layout
        vbox.Add(self.grid, 1, wx.EXPAND | wx.ALL, 3)
        vbox.Add(selbox, 3, wx.EXPAND | wx.ALL, 3)

        self.SetSizer(vbox)
Exemplo n.º 3
0
    def __init__(self, parent, event_handler):
        wx.Dialog.__init__(self, parent, -1, 'Demo Guide')

        self.event_handler = event_handler

        display_panel = wx.Panel(self, -1, style=wx.BORDER_SUNKEN)

        self.text = [
            'Welcome to the Demo\nClick Next to move on',
            'This is the tour through the GUI.\nThis GUI is serves as an interface\nto a time base controller. The\nController handles all the\nnecessary coordination functions\nof the system with time threads.',
            'This is the View Spectrum Panel.\nThis panel allows an operator to\nkeep an eye on the results\nof the DSA engine.',
            'This is the Graphical Spectrum\nPanel. This panel allows an\noperator to quickly see\nthe spectral usage.',
            'This is the Manage DSA Panel.\nThis panel allows an operator to\nmake requests for a frequency\nrelease a frequency orto change\nthe currently emphasised skill.',
            'This is the Add User Panel.\nThis panel allows an operator to\nadd a new team to the system,\nthe id for the team will be\nautomatically generated.',
            'This is the View Current Users\nPanel. This panel keeps an\noperator up to date on what\nteams are registered, where\nthey are, and what\ntheir skills are.'
        ]

        self.position = 0
        self.text_display = wx.StaticText(display_panel,
                                          -1,
                                          self.text[self.position],
                                          style=wx.ALIGN_CENTER)
        text_font = self.text_display.GetFont()
        text_font.SetPointSize(16)
        self.text_display.SetFont(text_font)

        button_panel = wx.Panel(self, -1)

        self.prev_button = wx.Button(button_panel, -1, "<-Previous")
        quit_button = wx.Button(button_panel, -1, "Quit")
        self.next_button = wx.Button(button_panel, -1, "Next->")

        self.prev_button.Disable()

        button_panel.Bind(wx.EVT_BUTTON, self.quit, id=quit_button.GetId())
        button_panel.Bind(wx.EVT_BUTTON,
                          self.button_handler,
                          id=self.prev_button.GetId())
        button_panel.Bind(wx.EVT_BUTTON,
                          self.button_handler,
                          id=self.next_button.GetId())

        big_box = wx.BoxSizer(wx.VERTICAL)
        self.display_box = wx.FlexGridSizer(2, 2, 2, 2)
        button_box = wx.GridSizer(1, 3, 2, 2)

        self.display_box.Add(wx.Size(0, 0), 0)
        self.display_box.Add(wx.Size(400, 0), 0)
        self.display_box.Add(wx.Size(0, 190), 0)
        self.display_box.Add(self.text_display, 0, wx.ALIGN_CENTER, 0)

        display_panel.SetSizer(self.display_box)

        button_box.Add(self.prev_button, 0, wx.EXPAND, 0)
        button_box.Add(quit_button, 0, wx.EXPAND, 0)
        button_box.Add(self.next_button, 0, wx.EXPAND, 0)

        button_panel.SetSizer(button_box)

        big_box.Add(display_panel, 0, wx.EXPAND | wx.ALL, 5)
        big_box.Add(button_panel, 0, wx.EXPAND | wx.ALL, 5)

        self.SetSizer(big_box)

        self.ShowModal()
        self.Destroy()
Exemplo n.º 4
0
 def __init__(self, parent, curvedict, correlations, labels=None):
     """ curvedict - dictionary, contains indexes to correlations and
                     labels. The keys are different types of curves
         correlations - list of correlations
         labels - list of labels for the correlations (e.g. filename+run)
                  if none, index numbers will be used for labels
     """
     # parent is the main frame of PyCorrFit
     self.parent = parent
     # init
     # super(ChooseImportTypesModel, self).__init__(parent=parent,
     #    title="Choose types", size=(250, 200))
     wx.Dialog.__init__(self, parent, -1, "Choose models")
     self.curvedict = curvedict
     self.kept_curvedict = curvedict.copy()  # Can be edited by user
     self.correlations = correlations
     self.labels = labels
     # List of keys that will be imported by our *parent*
     self.typekeys = list()
     # Dictionary of modelids corresponding to indices in curvedict
     self.modelids = dict()
     # Content
     self.panel = wx.Panel(self)
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.boxes = dict()
     labelim = "Select a fitting model for each correlation channel (AC,CC)."
     textinit = wx.StaticText(self.panel, label=labelim)
     self.sizer.Add(textinit)
     curvekeys = list(curvedict.keys())
     curvekeys.sort()
     self.curvekeys = curvekeys
     # Dropdown model selections:
     # Contains string in model dropdown
     DropdownList = ["No model selected"]
     self.DropdownIndex = [None]  # Contains corresponsing model
     modelkeys = list(mdls.modeltypes.keys())
     modelkeys.sort()
     for modeltype in modelkeys:
         for modelid in mdls.modeltypes[modeltype]:
             DropdownList.append(modeltype + ": " +
                                 mdls.modeldict[modelid][1])
             self.DropdownIndex.append(modelid)
     self.ModelDropdown = dict()
     dropsizer = wx.FlexGridSizer(rows=len(modelkeys),
                                  cols=3,
                                  vgap=5,
                                  hgap=5)
     self.Buttons = list()
     i = 8000
     for key in curvekeys:
         # Text with keys and numer of curves
         dropsizer.Add(wx.StaticText(self.panel, label=str(key)))
         label = " (" + str(len(curvedict[key])) + " curves)"
         button = wx.Button(self.panel, i, label)
         i += 1
         self.Bind(wx.EVT_BUTTON, self.OnSelectCurves, button)
         self.Buttons.append(button)
         dropsizer.Add(button)
         # Model selection dropdown
         dropdown = wx.ComboBox(self.panel, -1, DropdownList[0], (15, 30),
                                wx.DefaultSize, DropdownList,
                                wx.CB_DROPDOWN | wx.CB_READONLY)
         dropsizer.Add(dropdown)
         self.ModelDropdown[key] = dropdown
         self.Bind(wx.EVT_COMBOBOX, self.OnSetkeys, dropdown)
     self.sizer.Add(dropsizer)
     btnok = wx.Button(self.panel, wx.ID_OK, 'OK')
     # Binds the button to the function - close the tool
     self.Bind(wx.EVT_BUTTON, self.OnClose, btnok)
     self.sizer.Add(btnok)
     self.panel.SetSizer(self.sizer)
     self.sizer.Fit(self)
     # self.Show(True)
     self.SetFocus()
     if parent.MainIcon is not None:
         wx.Dialog.SetIcon(self, parent.MainIcon)
Exemplo n.º 5
0
    def __init__(self, parent, label, items1=None, groups=False, items2=None):
        super(HeaderDialog, self).__init__(parent,
                                           title='Choose headers',
                                           size=(500, 500))
        if groups:
            word = 'Groups'
        else:
            word = 'Headers'
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        listbox_sizer = wx.BoxSizer(wx.HORIZONTAL)
        if items1:
            box1 = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY, word, name='box1'),
                wx.HORIZONTAL)
            listbox1 = wx.ListBox(self,
                                  wx.ID_ANY,
                                  choices=items1,
                                  style=wx.LB_MULTIPLE,
                                  size=(200, 350))
            box1.Add(listbox1)
            listbox_sizer.Add(box1, flag=wx.ALL, border=5)
            self.Bind(wx.EVT_LISTBOX, self.on_click, listbox1)
            self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_click, listbox1)
        if items2:
            box2 = wx.StaticBoxSizer(
                wx.StaticBox(self,
                             wx.ID_ANY,
                             "Headers for interpretation data",
                             name='box2'), wx.HORIZONTAL)
            listbox2 = wx.ListBox(self,
                                  wx.ID_ANY,
                                  choices=items2,
                                  style=wx.LB_MULTIPLE,
                                  size=(200, 350))
            box2.Add(listbox2)
            listbox_sizer.Add(box2, flag=wx.ALL, border=5)
            self.Bind(wx.EVT_LISTBOX, self.on_click, listbox2)
            self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_click, listbox2)

        text_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self,
                         wx.ID_ANY,
                         'Adding {}:'.format(word.lower()),
                         name='text_box'), wx.HORIZONTAL)
        self.text_ctrl = wx.TextCtrl(self,
                                     id=-1,
                                     style=wx.TE_MULTILINE | wx.TE_READONLY,
                                     size=(420, 100))
        text_sizer.Add(self.text_ctrl)

        btn_ok = wx.Button(self, wx.ID_OK, label="OK")
        btn_ok.SetDefault()
        btn_cancel = wx.Button(self, wx.ID_CANCEL, label="Cancel")
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(btn_ok, flag=wx.ALIGN_CENTER | wx.ALL, border=10)
        hbox.Add(btn_cancel, flag=wx.ALIGN_CENTER | wx.ALL, border=10)

        main_sizer.Add(listbox_sizer, flag=wx.ALIGN_CENTER)
        main_sizer.Add(text_sizer, flag=wx.ALIGN_CENTER)
        main_sizer.Add(hbox, flag=wx.ALIGN_CENTER)

        self.SetSizer(main_sizer)
        main_sizer.Fit(self)

        self.text_list = []
Exemplo n.º 6
0
    def __init__(self, parent, size=(-1, -1), mixMatrix=None, offset=0.):
        wx.Dialog.__init__(self, parent, -1, 'Linear Unmixing', size=size)

        if not mixMatrix:
            mixMatrix = np.eye(2)

        vsizer = wx.BoxSizer(wx.VERTICAL)

        psizer = wx.BoxSizer(wx.HORIZONTAL)

        bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Mix Matrix'),
                                   wx.VERTICAL)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        self.tMM00 = wx.TextCtrl(self,
                                 -1,
                                 '%1.2f' % (mixMatrix[0, 0]),
                                 size=(40, -1))
        hsizer.Add(self.tMM00, 1, wx.ALL, 2)

        self.tMM01 = wx.TextCtrl(self,
                                 -1,
                                 '%1.2f' % (mixMatrix[0, 1]),
                                 size=(40, -1))
        hsizer.Add(self.tMM01, 1, wx.ALL, 2)

        bsizer.Add(hsizer, 0, wx.ALL, 0)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        self.tMM10 = wx.TextCtrl(self,
                                 -1,
                                 '%1.2f' % (mixMatrix[1, 0]),
                                 size=(40, -1))
        hsizer.Add(self.tMM10, 1, wx.ALL, 2)

        self.tMM11 = wx.TextCtrl(self,
                                 -1,
                                 '%1.2f' % (mixMatrix[1, 1]),
                                 size=(40, -1))
        hsizer.Add(self.tMM11, 1, wx.ALL, 2)

        bsizer.Add(hsizer, 0, wx.ALL, 0)

        psizer.Add(bsizer, 0, wx.ALL, 0)

        bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Offset'),
                                   wx.HORIZONTAL)
        self.tOffset = wx.TextCtrl(self, -1, '%1.2f' % (offset), size=(40, -1))
        #self.bOK = wx.Button(self, -1, 'OK', style = wx.BU_EXACTFIT)

        bsizer.Add(self.tOffset, 1, wx.ALL, 0)
        #bsizer.Add(self.bGrabOffset, 0, wx.LEFT, 5)
        psizer.Add(bsizer, 1, wx.LEFT | wx.RIGHT, 5)

        vsizer.Add(psizer, 1, wx.ALL | wx.EXPAND, 0)

        self.bOK = wx.Button(self, wx.ID_OK, 'OK')
        vsizer.Add(self.bOK, 0, wx.ALL | wx.EXPAND, 2)
        self.SetSizerAndFit(vsizer)
Exemplo n.º 7
0
import wx

app = wx.App()
win = wx.Frame(None, title="Py-Calc: La calculadora simple", size=(410, 335))

bkg = wx.Panel(win)

loadButton = wx.Button(bkg, label='Open')
saveButton = wx.Button(bkg, label='Save')
filename = wx.TextCtrl(bkg)
contents = wx.TextCtrl(bkg, style=wx.TE_MULTILINE | wx.HSCROLL)
hbox = wx.BoxSizer()
hbox.Add(filename, proportion=1, flag=wx.EXPAND)
hbox.Add(loadButton, proportion=0, flag=wx.LEFT, border=5)
hbox.Add(saveButton, proportion=0, flag=wx.LEFT, border=5)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(hbox, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
vbox.Add(contents,
         proportion=1,
         flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT,
         border=5)
bkg.SetSizer(vbox)

win.Show()
app.MainLoop()
Exemplo n.º 8
0
    def __init__(self, parent, document):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           title=Text.title,
                           style=wx.DEFAULT_DIALOG_STYLE)
        self.parent = parent
        self.choices = [""]
        textCtrl = wx.TextCtrl(self)
        wholeWordsOnlyCb = wx.CheckBox(self, -1, Text.wholeWordsOnly)
        caseSensitiveCb = wx.CheckBox(self, -1, Text.caseSensitive)
        searchParametersCb = wx.CheckBox(self, -1, Text.searchParameters)
        searchParametersCb.SetValue(1)
        directionRb = wx.RadioBox(self,
                                  label=Text.direction,
                                  choices=[Text.up, Text.down],
                                  style=wx.RA_SPECIFY_ROWS)
        directionRb.SetSelection(1)
        searchButton = wx.Button(self, -1, Text.findButton)
        searchButton.SetDefault()
        searchButton.Enable(False)
        cancelButton = wx.Button(self, wx.ID_CANCEL, eg.text.General.cancel)

        acv = wx.ALIGN_CENTER_VERTICAL
        upperLeftSizer = eg.HBoxSizer(
            (wx.StaticText(self, -1, Text.searchLabel), 0, acv | wx.RIGHT, 5),
            (textCtrl, 1, wx.EXPAND),
        )
        cbSizer = eg.VBoxSizer(
            (wholeWordsOnlyCb),
            (caseSensitiveCb, 0, wx.TOP, 5),
            (searchParametersCb, 0, wx.TOP, 5),
        )
        lowerLeftSizer = eg.HBoxSizer(
            (cbSizer, 0, acv | wx.RIGHT, 10),
            (directionRb),
        )
        leftSizer = eg.VBoxSizer(
            (upperLeftSizer, 0, wx.EXPAND | wx.ALL, 5),
            (lowerLeftSizer, 0, wx.EXPAND | wx.ALL, 5),
        )
        btnSizer = eg.VBoxSizer(
            (searchButton, 0, wx.EXPAND),
            (cancelButton, 0, wx.EXPAND | wx.TOP, 5),
        )
        sizer = eg.HBoxSizer(
            (leftSizer, 1, wx.EXPAND),
            (btnSizer, 0, wx.EXPAND | wx.ALL, 5),
        )
        self.SetSizerAndFit(sizer)
        self.SetMinSize(self.GetSize())

        searchButton.Bind(wx.EVT_BUTTON, self.OnFindButton)

        def EnableSearchButton(event):
            enable = textCtrl.GetValue() != ""
            searchButton.Enable(enable)

        textCtrl.Bind(wx.EVT_TEXT, EnableSearchButton)

        self.textCtrl = textCtrl
        self.wholeWordsOnlyCb = wholeWordsOnlyCb
        self.caseSensitiveCb = caseSensitiveCb
        self.searchParametersCb = searchParametersCb
        self.directionRb = directionRb
        self.searchButton = searchButton
Exemplo n.º 9
0
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FLC, name='flc', parent=prnt,
              pos=wx.Point(457, 381), size=wx.Size(363, 236),
              style=wx.DEFAULT_FRAME_STYLE^wx.MAXIMIZE_BOX^wx.RESIZE_BORDER,
              title='[ File Location Calculator ]')
        self.SetClientSize(wx.Size(347, 200))
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.addresses = wx.StaticBox(id=wxID_FLCADDRESSES, label='Addresses',
              name='addresses', parent=self, pos=wx.Point(8, 8),
              size=wx.Size(248, 100), style=0)

        self.additional_information = wx.StaticBox(id=wxID_FLCADDITIONAL_INFORMATION,
              label='Additional Information', name='additional_information',
              parent=self, pos=wx.Point(8, 112), size=wx.Size(248, 80),
              style=0)

        self.convert = wx.Button(id=wxID_FLCCONVERT, label='Convert',
              name='convert', parent=self, pos=wx.Point(264, 16),
              size=wx.Size(75, 23), style=0)

        self.hexedit = wx.Button(id=wxID_FLCHEXEDIT, label='Hex Edit',
              name='hexedit', parent=self, pos=wx.Point(264, 168),
              size=wx.Size(75, 23), style=0)

        self.section = wx.StaticText(id=wxID_FLCSECTION, label='Section',
              name='section', parent=self, pos=wx.Point(24, 136),
              size=wx.Size(36, 13), style=0)

        self.bytes = wx.StaticText(id=wxID_FLCBYTES, label='Bytes',
              name='bytes', parent=self, pos=wx.Point(24, 160), size=wx.Size(28,
              13), style=0)

        self._va = wx.TextCtrl(id=wxID_FLC_VA, name='_va', parent=self,
              pos=wx.Point(144, 24), size=wx.Size(100, 21), style=0, value='')

        self._rva = wx.TextCtrl(id=wxID_FLC_RVA, name='_rva', parent=self,
              pos=wx.Point(144, 48), size=wx.Size(100, 21), style=0, value='')

        self._offset = wx.TextCtrl(id=wxID_FLC_OFFSET, name='_offset',
              parent=self, pos=wx.Point(144, 72), size=wx.Size(100, 21),
              style=0, value='')

        self._section = wx.TextCtrl(id=wxID_FLC_SECTION, name='_section',
              parent=self, pos=wx.Point(144, 136), size=wx.Size(100, 21),
              style=0, value='')

        self._bytes = wx.TextCtrl(id=wxID_FLC_BYTES, name='_bytes', parent=self,
              pos=wx.Point(88, 160), size=wx.Size(156, 21), style=0, value='')

        self.va = wx.Button(id=wxID_FLCVA, label='VA', name='va', parent=self,
              pos=wx.Point(32, 24), size=wx.Size(75, 23), style=wx.NO_BORDER)

        self.rva = wx.Button(id=wxID_FLCRVA, label='RVA', name='rva',
              parent=self, pos=wx.Point(32, 48), size=wx.Size(75, 23), style=wx.NO_BORDER)

        self.offset = wx.Button(id=wxID_FLCOFFSET, label='Offset',
              name='offset', parent=self, pos=wx.Point(32, 72), size=wx.Size(75,
              23), style=wx.NO_BORDER)

        # we do not have an hex editor rigth now so we must hide this button.
        self.hexedit.Enable(False)
        self.hexedit.Hide()
        
        self._va.Enable(False)
        self._offset.Enable(False)
        
        self.va.Bind(wx.EVT_BUTTON, self.OnVAButton, id=wxID_FLCVA)
        self.offset.Bind(wx.EVT_BUTTON, self.OnOffsetButton, id=wxID_FLCOFFSET)
        self.rva.Bind(wx.EVT_BUTTON, self.OnRVAButton, id=wxID_FLCRVA)
        self.convert.Bind(wx.EVT_BUTTON, self.OnConvertButton, id=wxID_FLCCONVERT)
Exemplo n.º 10
0
    def __init__(self, parent, config):
        super(MainFrame, self).__init__("DeepLabCut - Refinement ToolBox",
                                        parent)
        self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyPressed)

        ###################################################################################################################################################

        # Spliting the frame into top and bottom panels. Bottom panels contains the widgets. The top panel is for showing images and plotting!

        topSplitter = wx.SplitterWindow(self)
        vSplitter = wx.SplitterWindow(topSplitter)

        self.image_panel = ImagePanel(vSplitter, config, self.gui_size)
        self.choice_panel = ScrollPanel(vSplitter)
        # self.choice_panel.SetupScrolling(scroll_x=True, scroll_y=True, scrollToTop=False)
        # self.choice_panel.SetupScrolling(scroll_x=True, scrollToTop=False)
        vSplitter.SplitVertically(self.image_panel,
                                  self.choice_panel,
                                  sashPosition=self.gui_size[0] * 0.8)
        vSplitter.SetSashGravity(1)
        self.widget_panel = WidgetPanel(topSplitter)
        topSplitter.SplitHorizontally(vSplitter,
                                      self.widget_panel,
                                      sashPosition=self.gui_size[1] *
                                      0.83)  # 0.9
        topSplitter.SetSashGravity(1)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(topSplitter, 1, wx.EXPAND)
        self.SetSizer(sizer)

        ###################################################################################################################################################
        # Add Buttons to the WidgetPanel and bind them to their respective functions.

        widgetsizer = wx.WrapSizer(orient=wx.HORIZONTAL)
        self.load = wx.Button(self.widget_panel,
                              id=wx.ID_ANY,
                              label="Load labels")
        widgetsizer.Add(self.load, 1, wx.ALL, 15)
        self.load.Bind(wx.EVT_BUTTON, self.browseDir)

        self.prev = wx.Button(self.widget_panel,
                              id=wx.ID_ANY,
                              label="<<Previous")
        widgetsizer.Add(self.prev, 1, wx.ALL, 15)
        self.prev.Bind(wx.EVT_BUTTON, self.prevImage)
        self.prev.Enable(False)

        self.next = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Next>>")
        widgetsizer.Add(self.next, 1, wx.ALL, 15)
        self.next.Bind(wx.EVT_BUTTON, self.nextImage)
        self.next.Enable(False)

        self.help = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Help")
        widgetsizer.Add(self.help, 1, wx.ALL, 15)
        self.help.Bind(wx.EVT_BUTTON, self.helpButton)
        self.help.Enable(True)

        self.zoom = wx.ToggleButton(self.widget_panel, label="Zoom")
        widgetsizer.Add(self.zoom, 1, wx.ALL, 15)
        self.zoom.Bind(wx.EVT_TOGGLEBUTTON, self.zoomButton)
        self.widget_panel.SetSizer(widgetsizer)
        self.zoom.Enable(False)

        self.home = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Home")
        widgetsizer.Add(self.home, 1, wx.ALL, 15)
        self.home.Bind(wx.EVT_BUTTON, self.homeButton)
        self.widget_panel.SetSizer(widgetsizer)
        self.home.Enable(False)

        self.pan = wx.ToggleButton(self.widget_panel,
                                   id=wx.ID_ANY,
                                   label="Pan")
        widgetsizer.Add(self.pan, 1, wx.ALL, 15)
        self.pan.Bind(wx.EVT_TOGGLEBUTTON, self.panButton)
        self.widget_panel.SetSizer(widgetsizer)
        self.pan.Enable(False)

        self.lock = wx.CheckBox(self.widget_panel,
                                id=wx.ID_ANY,
                                label="Lock View")
        widgetsizer.Add(self.lock, 1, wx.ALL, 15)
        self.lock.Bind(wx.EVT_CHECKBOX, self.lockChecked)
        self.widget_panel.SetSizer(widgetsizer)
        self.lock.Enable(False)

        self.save = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Save")
        widgetsizer.Add(self.save, 1, wx.ALL, 15)
        self.save.Bind(wx.EVT_BUTTON, self.saveDataSet)
        self.save.Enable(False)

        widgetsizer.AddStretchSpacer(15)
        self.quit = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Quit")
        widgetsizer.Add(self.quit, 1, wx.ALL, 15)
        self.quit.Bind(wx.EVT_BUTTON, self.quitButton)

        self.widget_panel.SetSizer(widgetsizer)
        self.widget_panel.SetSizerAndFit(widgetsizer)
        self.widget_panel.Layout()

        ###############################################################################################################################
        # Variable initialization
        self.currentDirectory = os.getcwd()
        self.index = []
        self.iter = []
        self.threshold = []
        self.file = 0
        self.updatedCoords = []
        self.drs = []
        self.cfg = auxiliaryfunctions.read_config(config)
        self.humanscorer = self.cfg["scorer"]
        self.move2corner = self.cfg["move2corner"]
        self.center = self.cfg["corner2move2"]
        self.colormap = plt.get_cmap(self.cfg["colormap"])
        self.colormap = self.colormap.reversed()
        self.markerSize = self.cfg["dotsize"]
        self.alpha = self.cfg["alphavalue"]
        self.iterationindex = self.cfg["iteration"]
        self.project_path = self.cfg["project_path"]
        self.bodyparts = self.cfg["bodyparts"]
        self.threshold = 0.1
        self.img_size = (10, 6)  # (imgW, imgH)  # width, height in inches.
        self.preview = False
        self.view_locked = False
        # Workaround for MAC - xlim and ylim changed events seem to be triggered too often so need to make sure that the
        # xlim and ylim have actually changed before turning zoom off
        self.prezoom_xlim = []
        self.prezoom_ylim = []
        from deeplabcut.utils import auxfun_multianimal

        (
            self.individual_names,
            self.uniquebodyparts,
            self.multianimalbodyparts,
        ) = auxfun_multianimal.extractindividualsandbodyparts(self.cfg)
        # self.choiceBox,self.visualization_rdb = self.choice_panel.addRadioButtons()
        self.Colorscheme = visualization.get_cmap(len(self.individual_names),
                                                  self.cfg["colormap"])
Exemplo n.º 11
0
    def __init__(self, parent):
        wx.Dialog.__init__ (self, parent, id = wx.ID_ANY,
                             title = u"Join PDF files",
                             pos = defPos,
                             size = wx.Size(900,710),
                             style = wx.CAPTION|
                                     wx.CLOSE_BOX|
                                     wx.DEFAULT_DIALOG_STYLE|
                                     wx.MAXIMIZE_BOX|
                                     wx.MINIMIZE_BOX|
                                     wx.RESIZE_BORDER)
        self.FileList = {}
        if show_icon: self.SetIcon(ico_pdf.img.GetIcon())
        self.SetBackgroundColour(khaki)

#==============================================================================
# Create Sizer 01 (browse button and explaining text)
#==============================================================================
        szr01 = wx.BoxSizer(wx.HORIZONTAL)

        self.btn_neu = wx.FilePickerCtrl(self, wx.ID_ANY,
                        wx.EmptyString,
                        u"Select a PDF file",
                        u"*.pdf",
                        defPos, defSiz,
                        wx.FLP_CHANGE_DIR|wx.FLP_FILE_MUST_EXIST|wx.FLP_SMALL,
                        )
        szr01.Add(self.btn_neu, 0, wx.ALIGN_TOP|wx.ALL, 5)

        msg_txt ="""ADD files with this button. Path and total page number will be appended to the table below.\nDUPLICATE row: double-click its number. MOVE row: drag its number with the mouse. DELETE row: CTRL+RightClick its number."""
        msg = wx.StaticText(self, wx.ID_ANY, msg_txt,
                    defPos, wx.Size(-1, 50), wx.ALIGN_LEFT)
        msg.Wrap(-1)
        msg.SetFont(wx.Font(10, 74, 90, 90, False, "Arial"))

        szr01.Add(msg, 0, wx.ALIGN_TOP|wx.ALL, 5)

#==============================================================================
# Create Sizer 02 (contains the grid)
#==============================================================================
        self.szr02 = MyGrid(self)
        self.szr02.AutoSizeColumn(0)
        self.szr02.AutoSizeColumn(1)
        self.szr02.SetColSize(2, 45)
        self.szr02.SetColSize(3, 45)
        self.szr02.SetColSize(4, 45)
        self.szr02.SetRowLabelSize(30)
        # Columns 1 and 2 are read only
        attr_ro = gridlib.GridCellAttr()
        attr_ro.SetReadOnly(True)
        self.szr02.SetColAttr(0, attr_ro)
        self.szr02.SetColAttr(1, attr_ro)

#==============================================================================
# Create Sizer 03 (output parameters)
#==============================================================================
        szr03 = wx.FlexGridSizer( 6, 2, 0, 0 )   # 6 rows, 2 cols, gap sizes 0
        szr03.SetFlexibleDirection( wx.BOTH )
        szr03.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )

        tx_ausdat = wx.StaticText(self, wx.ID_ANY, u"Output:",
                            defPos, defSiz, 0)
        szr03.Add(tx_ausdat, 0, wx.ALL|wx.ALIGN_RIGHT, 5)

        self.btn_aus = wx.FilePickerCtrl(self, wx.ID_ANY,
                        os.path.join(os.path.expanduser('~'), "joined.pdf"),
                        u"Specify output file",
                        u"*.pdf",
                        defPos, wx.Size(480,-1),
                        wx.FLP_OVERWRITE_PROMPT|
                        wx.FLP_SAVE|wx.FLP_SMALL|
                        wx.FLP_USE_TEXTCTRL)
        szr03.Add(self.btn_aus, 0, wx.ALL, 5)

        tx_autor = wx.StaticText( self, wx.ID_ANY, u"Author:",
                         defPos, defSiz, 0 )
        szr03.Add( tx_autor, 0, wx.ALIGN_RIGHT, 5 )

        self.ausaut = wx.TextCtrl( self, wx.ID_ANY,
                       os.path.basename(os.path.expanduser('~')),
                       defPos, wx.Size(480, -1), wx.NO_BORDER)
        szr03.Add( self.ausaut, 0, wx.LEFT, 5 )

        pdf_titel = wx.StaticText( self, wx.ID_ANY, u"Title:",
                          defPos, defSiz, 0 )
        szr03.Add( pdf_titel, 0, wx.ALIGN_RIGHT, 5 )

        self.austit = wx.TextCtrl( self, wx.ID_ANY, u"Joined PDF files",
                       defPos, wx.Size(480, -1), wx.NO_BORDER )
        szr03.Add( self.austit, 0, wx.LEFT, 5 )

        tx_subject = wx.StaticText( self, wx.ID_ANY, u"Subject:",
                           defPos, defSiz, wx.ALIGN_RIGHT)
        szr03.Add( tx_subject, 0, wx.ALIGN_RIGHT, 5 )

        self.aussub = wx.TextCtrl( self, wx.ID_ANY, u"Joined PDF files",
                       defPos, wx.Size(480, -1), wx.NO_BORDER )
        szr03.Add( self.aussub, 0, wx.LEFT, 5 )

        tx_keywords = wx.StaticText(self, wx.ID_ANY, "Keywords:",
                           defPos, defSiz, 0)
        szr03.Add(tx_keywords, 0, wx.ALIGN_RIGHT, 5)

        self.keywords = wx.TextCtrl(self, wx.ID_ANY, u" ",
                       defPos, wx.Size(480, -1), wx.NO_BORDER)
        szr03.Add(self.keywords, 0, wx.LEFT, 5)
        tx_blank = wx.StaticText( self, wx.ID_ANY, u" ",
                           defPos, defSiz, wx.ALIGN_RIGHT)
        szr03.Add( tx_blank, 0, wx.RIGHT, 5 )
        self.noToC = wx.CheckBox( self, wx.ID_ANY,
                           u"no table of content",
                           defPos, defSiz, wx.ALIGN_LEFT)
        szr03.Add( self.noToC, 0, wx.ALL, 5 )


#==============================================================================
# Create Sizer 04 (OK / Cancel buttons)
#==============================================================================
        szr04 = wx.StdDialogButtonSizer()
        szr04OK = wx.Button(self, wx.ID_OK, "SAVE",
                            defPos, defSiz, wx.BU_EXACTFIT)
        szr04.AddButton(szr04OK)
        szr04Cancel = wx.Button(self, wx.ID_CANCEL, "QUIT",
                                defPos, defSiz, wx.BU_EXACTFIT)
        szr04.AddButton(szr04Cancel)
        szr04.Realize();

#==============================================================================
# 3 horizontal lines (decoration only)
#==============================================================================
        linie1 = wx.StaticLine(self, wx.ID_ANY,
                       defPos, defSiz, wx.LI_HORIZONTAL)
        linie2 = wx.StaticLine(self, wx.ID_ANY,
                       defPos, defSiz, wx.LI_HORIZONTAL)
        linie3 = wx.StaticLine(self, wx.ID_ANY,
                       defPos, defSiz, wx.LI_HORIZONTAL)

        mainszr = wx.BoxSizer(wx.VERTICAL)
        mainszr.Add(szr01, 0, wx.EXPAND, 5)
        mainszr.Add(linie1, 0, wx.EXPAND |wx.ALL, 5)
        mainszr.Add(self.szr02, 1, wx.EXPAND, 5)
        mainszr.Add(linie2, 0, wx.EXPAND|wx.ALL, 5)
        mainszr.Add(szr03, 0, wx.EXPAND|wx.ALL, 5)
        mainszr.Add(linie3, 0, wx.EXPAND |wx.ALL, 5)
        mainszr.Add(szr04, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        self.SetSizer(mainszr)
        self.Layout()

        self.Centre(wx.BOTH)

#==============================================================================
# Define event handlers for the buttons
#==============================================================================
        self.btn_neu.Bind(wx.EVT_FILEPICKER_CHANGED, self.NewFile)
        self.btn_aus.Bind(wx.EVT_FILEPICKER_CHANGED, self.AusgabeDatei)
Exemplo n.º 12
0
    def __init__(self, parent, *args, devices=[], **kwargs):
        wx.Panel.__init__(self, parent, *args, **kwargs)
        self._Thread = None
        self._Benchmarking = False
        self._Devices = devices
        self._Settings = self._Benchmarks = None

        pub.subscribe(self._OnSettings, 'data.settings')
        pub.subscribe(self._OnBenchmarks, 'data.benchmarks')

        pub.subscribe(self._OnStartBenchmarking, 'benchmarking.start')
        pub.subscribe(self._OnStopBenchmarking, 'benchmarking.stop')

        pub.subscribe(self._OnClose, 'app.close')

        pub.subscribe(self._OnNewBalance, 'nicehash.balance')
        pub.subscribe(self._OnMiningStatus, 'mining.status')

        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        self.SetSizer(sizer)

        # Update balance periodically.
        self._Timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, lambda event: self._UpdateBalance(), self._Timer)
        self._Timer.Start(milliseconds=BALANCE_UPDATE_MIN*60*1e3)

        # Add mining panel.
        self._Panel = MiningPanel(self, style=wx.dataview.DV_HORIZ_RULES)
        sizer.Add(self._Panel, wx.SizerFlags().Border(wx.LEFT|wx.RIGHT|wx.TOP,
                                                      main.PADDING_PX)
                                              .Proportion(1.0)
                                              .Expand())

        bottomSizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        sizer.Add(bottomSizer, wx.SizerFlags().Border(wx.ALL, main.PADDING_PX)
                                              .Expand())

        # Add balance displays.
        balances = wx.FlexGridSizer(2, 2, main.PADDING_PX)
        balances.AddGrowableCol(1)
        bottomSizer.Add(balances, wx.SizerFlags().Proportion(1.0).Expand())

        balances.Add(wx.StaticText(self, label='Daily revenue'))
        self._Revenue = wx.StaticText(
            self, style=wx.ALIGN_RIGHT|wx.ST_NO_AUTORESIZE)
        self._Revenue.SetFont(self.GetFont().Bold())
        balances.Add(self._Revenue, wx.SizerFlags().Expand())

        balances.Add(wx.StaticText(self, label='Address balance'))
        self._Balance = wx.StaticText(
            self, style=wx.ALIGN_RIGHT|wx.ST_NO_AUTORESIZE)
        self._Balance.SetFont(self.GetFont().Bold())
        balances.Add(self._Balance, wx.SizerFlags().Expand())

        bottomSizer.AddSpacer(main.PADDING_PX)

        # Add start/stop button.
        self._StartStop = wx.Button(self, label='Start Mining')
        bottomSizer.Add(self._StartStop, wx.SizerFlags().Expand()
                                                        .Center())
        self.Bind(wx.EVT_BUTTON, self.OnStartStop, self._StartStop)
Exemplo n.º 13
0
    def __init__(self, titles, toplabel):
        wx.Frame.__init__(self, None, -1, title=titles)
        panel = wx.Panel(self, -1)

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.server = MyServerTcp()

        self.bthread = False
        #首先建立需要建立的标签
        #文字信息
        toplabel = wx.StaticText(panel, -1, "simple test")
        toplabel.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))

        addrsssLabel = wx.StaticText(panel, -1, "IP地址:")
        self.address = wx.TextCtrl(panel, -1, "localhost")

        portLabel = wx.StaticText(panel, -1, "port:")
        self.port = wx.TextCtrl(panel, -1, "8000")

        self.shore = wx.TextCtrl(panel,
                                 -1,
                                 "",
                                 size=(300, 400),
                                 style=wx.TE_MULTILINE | wx.TE_RICH2)

        self.input = wx.TextCtrl(panel, -1, "", size=(200, -1))
        buttonListen = wx.Button(panel, -1, "Listen")
        self.Listenbutton = buttonListen
        self.Bind(wx.EVT_BUTTON, self.OnListen, buttonListen)

        buttonSend = wx.Button(panel, -1, "send")
        buttonSend.Enable(False)
        self.Sendbutton = buttonSend
        self.Bind(wx.EVT_BUTTON, self.OnSend, buttonSend)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(toplabel, 0, wx.ALL, 5)
        #mainSizer.Add(wx.StaticLine(panel),0,wx.EXPAND|wx.TOP,wx.BOTTOM,5)

        #添加ip地址
        addrSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        addrSizer.AddGrowableCol(1)
        addrSizer.Add(addrsssLabel, 0,
                      wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.address, 0, wx.EXPAND)
        addrSizer.Add(portLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(self.port, 0, wx.EXPAND)
        addrSizer.Add(wx.StaticText(panel, -1, ""), 0,
                      wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)

        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)

        buttonSizer.Add(self.input, 0, wx.EXPAND)
        buttonSizer.Add((20, 20), 1)
        buttonSizer.Add(buttonSend)
        buttonSizer.Add((20, 20), 1)

        mainSizer.Add(addrSizer, 0, wx.EXPAND | wx.ALL, 10)
        mainSizer.Add(buttonListen, 0, wx.ALIGN_CENTER_HORIZONTAL)
        mainSizer.Add(self.shore, 0, wx.EXPAND | wx.ALL, 10)
        mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL, 10)

        panel.SetSizer(mainSizer)
        mainSizer.Fit(self)
        mainSizer.SetSizeHints(self)
Exemplo n.º 14
0
    def createWidgets(self):
        img = wx.EmptyImage(800, 0)
        self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY,
                                         wx.BitmapFromImage(img))

        Line_0 = wx.StaticText(
            self.panel, label='Please submit all the requested information')

        Line_1 = wx.StaticText(self.panel, label='image/video path:     ')
        self.path = wx.TextCtrl(self.panel, size=(450, -1))
        self.path.SetValue(str('Please browse the image/video file'))
        Submit_path = wx.Button(self.panel, label='Browse ...')
        Submit_path.Bind(wx.EVT_BUTTON, self.Path)

        Line_2 = wx.StaticText(self.panel, label='plate size (mm):          ')
        self.platesize = wx.TextCtrl(self.panel, size=(450, -1))
        self.platesize.SetValue(str(1000))
        Submit_platesize = wx.Button(self.panel, label='Submit')
        Submit_platesize.Bind(wx.EVT_BUTTON, self.PlateSize)

        Line_3 = wx.StaticText(self.panel,
                               label='select black or green or blue ')
        Line_3_1 = wx.StaticText(self.panel, label='plate tapped colour: ')
        self.platecolour = wx.TextCtrl(self.panel, size=(450, -1))
        self.platecolour.SetValue(
            str('Please insert the plate tappped colour'))
        Submit_platecolour = wx.Button(self.panel, label='Submit')
        Submit_platecolour.Bind(wx.EVT_BUTTON, self.PlateColour)

        #Line_4 = wx.StaticText(self.panel, label='cone tapped colour:  ')
        #self.conecolour = wx.TextCtrl(self.panel, size=(450,-1))
        #self.conecolour.SetValue(str('Please insert the cone tappped colour'))
        #Submit_conecolour = wx.Button(self.panel, label='Submit')
        #Submit_conecolour.Bind(wx.EVT_BUTTON, self.ConeColour)

        Line_5 = wx.StaticText(
            self.panel, label='Please select one of bellow test types: ')

        SCC_image = wx.Button(self.panel, label='  SCC-image test  ')
        SCC_image.Bind(wx.EVT_BUTTON, self.SCCImage)

        SCC_video = wx.Button(self.panel, label='  SCC-video test  ')
        SCC_video.Bind(wx.EVT_BUTTON, self.SCCVideo)

        SLUMP_image = wx.Button(self.panel, label='  SLUMP-image test  ')
        SLUMP_image.Bind(wx.EVT_BUTTON, self.SLUMPImage)

        SLUMP_video = wx.Button(self.panel, label='  SLUMP-video test  ')
        SLUMP_video.Bind(wx.EVT_BUTTON, self.SLUMPVideo)

        Line_7 = wx.StaticText(self.panel, label='Results:  ')
        Line_7_1 = wx.StaticText(self.panel, label=' East-West diameter (mm) ')
        self.ew_diameter = wx.TextCtrl(self.panel, size=(100, -1))
        self.ew_diameter.SetValue(str(0.0))
        Line_7_2 = wx.StaticText(self.panel, label=' Height (mm) ')
        self.height = wx.TextCtrl(self.panel, size=(100, -1))
        self.height.SetValue(str(0.0))
        Line_7_3 = wx.StaticText(self.panel, label=' Test time (ms) ')
        self.time = wx.TextCtrl(self.panel, size=(100, -1))
        self.time.SetValue(str(0.0))

        Line_8 = wx.StaticText(self.panel, label='Situation: ')
        self.situation = wx.TextCtrl(self.panel, size=(600, -1))
        self.situation.SetValue(str('I am waiting...'))

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer0 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer1 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer3 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer3_1 = wx.BoxSizer(wx.HORIZONTAL)
        #self.sizer4 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer5 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer6 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer7 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer8 = wx.BoxSizer(wx.HORIZONTAL)

        self.mainSizer.Add(self.imageCtrl, 0, wx.ALL, 5)

        self.sizer0.Add(Line_0, 0, wx.ALL | wx.CENTER, 5)

        self.sizer1.Add(Line_1, 0, wx.ALL, 5)
        self.sizer1.Add(self.path, 0, wx.ALL, 5)
        self.sizer1.Add(Submit_path, 0, wx.ALL, 5)

        self.sizer2.Add(Line_2, 0, wx.ALL, 5)
        self.sizer2.Add(self.platesize, 0, wx.ALL, 5)
        self.sizer2.Add(Submit_platesize, 0, wx.ALL, 5)

        self.sizer3.Add(Line_3, 0, wx.ALL, 5)
        self.sizer3_1.Add(Line_3_1, 0, wx.ALL, 5)
        self.sizer3_1.Add(self.platecolour, 0, wx.ALL, 5)
        self.sizer3_1.Add(Submit_platecolour, 0, wx.ALL, 5)

        #self.sizer4.Add(Line_4, 0, wx.ALL, 5)
        #self.sizer4.Add(self.conecolour, 0, wx.ALL, 5)
        #self.sizer4.Add(Submit_conecolour, 0, wx.ALL, 5)

        self.sizer5.Add(Line_5, 0, wx.ALL | wx.CENTER, 5)

        self.sizer6.Add(SCC_image, 0, wx.ALL, 5)
        self.sizer6.Add(SCC_video, 0, wx.ALL, 5)
        self.sizer6.Add(SLUMP_image, 0, wx.ALL, 5)
        self.sizer6.Add(SLUMP_video, 0, wx.ALL, 5)

        self.sizer7.Add(Line_7, 0, wx.ALL, 5)
        self.sizer7.Add(Line_7_1, 0, wx.ALL, 5)
        self.sizer7.Add(self.ew_diameter, 0, wx.ALL, 5)
        self.sizer7.Add(Line_7_2, 0, wx.ALL, 5)
        self.sizer7.Add(self.height, 0, wx.ALL, 5)
        self.sizer7.Add(Line_7_3, 0, wx.ALL, 5)
        self.sizer7.Add(self.time, 0, wx.ALL, 5)

        self.sizer8.Add(Line_8, 0, wx.ALL, 5)
        self.sizer8.Add(self.situation, 0, wx.ALL, 5)

        self.mainSizer.Add(self.sizer0, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer1, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer2, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer3, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer3_1, 0, wx.ALL, 5)
        #self.mainSizer.Add(self.sizer4, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer5, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer6, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer7, 0, wx.ALL, 5)
        self.mainSizer.Add(self.sizer8, 0, wx.ALL, 5)

        self.panel.SetSizer(self.mainSizer)
        self.mainSizer.Fit(self.frame)
        self.panel.Layout()
Exemplo n.º 15
0
    def __init__(self, *args, **kw):
        super(MainFrame, self).__init__(*args, **kw)
        self.Bind(wx.EVT_CLOSE, self.onClose, self)

        self._pnlMain = wx.Panel(self)

        szLabel = wx.Size(100, 20)
        stText1 = wx.StaticText(self._pnlMain,
                                label="Text 1",
                                style=wx.ALIGN_RIGHT
                                | wx.ALIGN_CENTER_VERTICAL,
                                size=szLabel)

        szrText1 = wx.BoxSizer(wx.HORIZONTAL)
        szrText1.Add(stText1, wx.SizerFlags().Border(wx.LEFT, 10))

        szText = wx.Size(300, 20)
        self._txtText1 = wx.TextCtrl(self._pnlMain, size=szText)
        szrText1.Add(self._txtText1,
                     wx.SizerFlags().Border(wx.LEFT | wx.RIGHT, 10))

        szLabel = wx.Size(100, 20)
        stText2 = wx.StaticText(self._pnlMain,
                                label="Text 2",
                                style=wx.ALIGN_RIGHT
                                | wx.ALIGN_CENTER_VERTICAL,
                                size=szLabel)

        szrText2 = wx.BoxSizer(wx.HORIZONTAL)
        szrText2.Add(stText2, wx.SizerFlags().Border(wx.LEFT, 10))

        szText = wx.Size(300, 20)
        self._txtText2 = wx.TextCtrl(self._pnlMain, size=szText)
        szrText2.Add(self._txtText2,
                     wx.SizerFlags().Border(wx.LEFT | wx.RIGHT, 10))

        stLabel = wx.StaticText(self._pnlMain,
                                label="Lower Third",
                                style=wx.ALIGN_CENTER,
                                size=wx.Size(400, 50))
        font = stLabel.GetFont()
        font.PointSize += 10
        font = font.Bold()
        stLabel.SetFont(font)

        szButton = wx.Size(100, 100)
        btnLoad1 = wx.Button(self._pnlMain, label="Show 1", size=szButton)
        self.Bind(wx.EVT_BUTTON, self.onShow1, btnLoad1)

        szButton = wx.Size(100, 100)
        btnLoad2 = wx.Button(self._pnlMain, label="Show 2", size=szButton)
        self.Bind(wx.EVT_BUTTON, self.onShow2, btnLoad2)

        szrButtons = wx.BoxSizer(wx.HORIZONTAL)
        szrButtons.Add(btnLoad1, wx.SizerFlags().Border(wx.LEFT, 10))
        szrButtons.Add(btnLoad2, wx.SizerFlags().Border(wx.LEFT, 10))

        szrMain = wx.BoxSizer(wx.VERTICAL)
        szrMain.Add(stLabel, wx.SizerFlags().Border(wx.TOP, 20))
        szrMain.Add(szrText1, wx.SizerFlags().Border(wx.TOP, 10))
        szrMain.Add(szrText2, wx.SizerFlags().Border(wx.TOP, 10))
        szrMain.Add(szrButtons, wx.SizerFlags().Border(wx.TOP, 10))
        self._client = Connector.getConnector()
        self._pnlMain.SetSizerAndFit(szrMain)
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Smach Viewer", size=(720, 480))

        # Create graph
        self._containers = {}
        self._top_containers = {}
        self._update_cond = threading.Condition()
        self._needs_refresh = True
        self.dotstr = ''

        vbox = wx.BoxSizer(wx.VERTICAL)

        # Create Splitter
        self.content_splitter = wx.SplitterWindow(self,
                                                  -1,
                                                  style=wx.SP_LIVE_UPDATE)
        self.content_splitter.SetMinimumPaneSize(24)
        self.content_splitter.SetSashGravity(0.85)

        # Create viewer pane
        viewer = wx.Panel(self.content_splitter, -1)

        # Create smach viewer
        nb = wx.Notebook(viewer, -1, style=wx.NB_TOP | wx.WANTS_CHARS)
        viewer_box = wx.BoxSizer()
        viewer_box.Add(nb, 1, wx.EXPAND | wx.ALL, 4)
        viewer.SetSizer(viewer_box)

        # Create graph view
        graph_view = wx.Panel(nb, -1)
        gv_vbox = wx.BoxSizer(wx.VERTICAL)
        graph_view.SetSizer(gv_vbox)

        # Construct toolbar
        toolbar = wx.ToolBar(graph_view, -1)

        toolbar.AddControl(wx.StaticText(toolbar, -1, "Path: "))

        # Path list
        self.path_combo = wx.ComboBox(toolbar, -1, style=wx.CB_DROPDOWN)
        self.path_combo.Bind(wx.EVT_COMBOBOX, self.set_path)
        self.path_combo.Append('/')
        self.path_combo.SetValue('/')
        toolbar.AddControl(self.path_combo)

        # Depth spinner
        self.depth_spinner = wx.SpinCtrl(toolbar,
                                         -1,
                                         size=wx.Size(50, -1),
                                         min=-1,
                                         max=1337,
                                         initial=-1)
        self.depth_spinner.Bind(wx.EVT_SPINCTRL, self.set_depth)
        self._max_depth = -1
        toolbar.AddControl(wx.StaticText(toolbar, -1, "    Depth: "))
        toolbar.AddControl(self.depth_spinner)

        # Label width spinner
        self.width_spinner = wx.SpinCtrl(toolbar,
                                         -1,
                                         size=wx.Size(50, -1),
                                         min=1,
                                         max=1337,
                                         initial=40)
        self.width_spinner.Bind(wx.EVT_SPINCTRL, self.set_label_width)
        self._label_wrapper = textwrap.TextWrapper(40, break_long_words=True)
        toolbar.AddControl(wx.StaticText(toolbar, -1, "    Label Width: "))
        toolbar.AddControl(self.width_spinner)

        # Implicit transition display
        toggle_all = wx.ToggleButton(toolbar, -1, 'Show Implicit')
        toggle_all.Bind(wx.EVT_TOGGLEBUTTON, self.toggle_all_transitions)
        self._show_all_transitions = False

        toolbar.AddControl(wx.StaticText(toolbar, -1, "    "))
        toolbar.AddControl(toggle_all)

        toggle_auto_focus = wx.ToggleButton(toolbar, -1, 'Auto Focus')
        toggle_auto_focus.Bind(wx.EVT_TOGGLEBUTTON, self.toggle_auto_focus)
        self._auto_focus = False

        toolbar.AddControl(wx.StaticText(toolbar, -1, "    "))
        toolbar.AddControl(toggle_auto_focus)

        toolbar.AddControl(wx.StaticText(toolbar, -1, "    "))
        toolbar.AddLabelTool(
            wx.ID_HELP, 'Help',
            wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_OTHER, (16, 16)))
        toolbar.AddLabelTool(
            wx.ID_SAVE, 'Save',
            wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, (16, 16)))
        toolbar.Realize()

        self.Bind(wx.EVT_TOOL, self.ShowControlsDialog, id=wx.ID_HELP)
        self.Bind(wx.EVT_TOOL, self.SaveDotGraph, id=wx.ID_SAVE)

        # Create dot graph widget
        self.widget = xdot.wxxdot.WxDotWindow(graph_view, -1)

        gv_vbox.Add(toolbar, 0, wx.EXPAND)
        gv_vbox.Add(self.widget, 1, wx.EXPAND)

        # Create tree view widget
        self.tree = wx.TreeCtrl(nb, -1, style=wx.TR_HAS_BUTTONS)
        nb.AddPage(graph_view, "Graph View")
        nb.AddPage(self.tree, "Tree View")

        # Create userdata widget
        borders = wx.LEFT | wx.RIGHT | wx.TOP
        border = 4
        self.ud_win = wx.ScrolledWindow(self.content_splitter, -1)
        self.ud_gs = wx.BoxSizer(wx.VERTICAL)

        self.ud_gs.Add(wx.StaticText(self.ud_win, -1, "Path:"), 0, borders,
                       border)

        self.path_input = wx.ComboBox(self.ud_win, -1, style=wx.CB_DROPDOWN)
        self.path_input.Bind(wx.EVT_COMBOBOX, self.selection_changed)
        self.ud_gs.Add(self.path_input, 0, wx.EXPAND | borders, border)

        self.ud_gs.Add(wx.StaticText(self.ud_win, -1, "Userdata:"), 0, borders,
                       border)

        self.ud_txt = wx.TextCtrl(self.ud_win,
                                  -1,
                                  style=wx.TE_MULTILINE | wx.TE_READONLY)
        self.ud_gs.Add(self.ud_txt, 1, wx.EXPAND | borders, border)

        # Add initial state button
        self.is_button = wx.Button(self.ud_win, -1, "Set as Initial State")
        self.is_button.Bind(wx.EVT_BUTTON, self.on_set_initial_state)
        self.is_button.Disable()
        self.ud_gs.Add(self.is_button, 0, wx.EXPAND | wx.BOTTOM | borders,
                       border)

        self.ud_win.SetSizer(self.ud_gs)

        # Set content splitter
        self.content_splitter.SplitVertically(viewer, self.ud_win, 512)

        # Add statusbar
        self.statusbar = wx.StatusBar(self, -1)

        # Add elements to sizer
        vbox.Add(self.content_splitter, 1, wx.EXPAND | wx.ALL)
        vbox.Add(self.statusbar, 0, wx.EXPAND)

        self.SetSizer(vbox)
        self.Center()

        # smach introspection client
        self._client = smach_ros.IntrospectionClient()
        self._containers = {}
        self._selected_paths = []

        # Message subscribers
        self._structure_subs = {}
        self._status_subs = {}

        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.Bind(wx.EVT_CLOSE, self.OnQuit)

        # Register mouse event callback
        self.widget.register_select_callback(self.select_cb)
        self._path = '/'
        self._needs_zoom = True
        self._structure_changed = True

        # Start a thread in the background to update the server list
        self._keep_running = True
        self._server_list_thread = threading.Thread(
            target=self._update_server_list)
        self._server_list_thread.start()

        self._update_graph_thread = threading.Thread(target=self._update_graph)
        self._update_graph_thread.start()
        self._update_tree_thread = threading.Thread(target=self._update_tree)
        self._update_tree_thread.start()
Exemplo n.º 17
0
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, u'CM升级工具', size=(600, 400))

        # 创建面板

        panel = wx.Panel(self)

        # 创建按钮
        self.bt_FlipHoriz = wx.Button(panel, label='水平翻转')
        self.bt_FlipVert = wx.Button(panel, label='垂直翻转')
        self.bt_MidBase = wx.Button(panel, label='居中白底')  # 确定白底像素
        self.bt_AddWrite = wx.Button(panel, label='添加白底')

        # 创建文本

        self.lb_FilePath = wx.StaticText(panel, 0, u"文件路径:", style=wx.TE_LEFT)
        self.lb_Pixel = wx.StaticText(panel, 0, u"像      素:", style=wx.TE_LEFT)
        self.txt_FilePath = wx.TextCtrl(panel,
                                        style=wx.TE_LEFT,
                                        value=u'请选择图片目录')
        self.txt_Pixel = wx.TextCtrl(panel, style=wx.TE_LEFT, value=u'请输入像素')
        # 创建文本内容框,多行,垂直滚动条
        self.text_contents = wx.TextCtrl(panel,
                                         style=wx.TE_MULTILINE | wx.HSCROLL)

        # 添加容器
        bsizer_top = wx.BoxSizer(wx.HORIZONTAL)

        bsizer_center = wx.BoxSizer(wx.HORIZONTAL)

        bsizer_botton1 = wx.BoxSizer(wx.VERTICAL)
        bsizer_botton2 = wx.BoxSizer(wx.VERTICAL)
        bsizer_content = wx.BoxSizer(wx.HORIZONTAL)

        # 容器中添加控件
        bsizer_top.Add(self.lb_FilePath,
                       proportion=0,
                       flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT,
                       border=5)
        bsizer_top.Add(self.txt_FilePath,
                       proportion=2,
                       flag=wx.EXPAND | wx.ALL,
                       border=5)

        bsizer_center.Add(self.lb_Pixel,
                          proportion=0,
                          flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL
                          | wx.ALIGN_LEFT,
                          border=5)
        bsizer_center.Add(self.txt_Pixel,
                          proportion=2,
                          flag=wx.EXPAND | wx.ALL,
                          border=5)

        bsizer_botton1.Add(self.bt_FlipHoriz,
                           proportion=1,
                           flag=wx.ALL,
                           border=5)
        bsizer_botton1.Add(self.bt_FlipVert,
                           proportion=1,
                           flag=wx.ALL,
                           border=5)
        bsizer_botton1.Add(self.bt_MidBase,
                           proportion=1,
                           flag=wx.ALL,
                           border=5)
        bsizer_botton2.Add(self.bt_AddWrite,
                           proportion=1,
                           flag=wx.ALL,
                           border=5)
        bsizer_content.Add(self.text_contents,
                           proportion=1,
                           flag=wx.EXPAND | wx.ALL,
                           border=5)

        # wx.VERTICAL 横向分割
        bsizer_all = wx.BoxSizer(wx.VERTICAL)
        # 添加顶部sizer,proportion=0 代表bsizer_top大小不可变化
        bsizer_all.Add(bsizer_top,
                       proportion=0,
                       flag=wx.EXPAND | wx.ALL,
                       border=5)
        bsizer_all.Add(bsizer_center,
                       proportion=0,
                       flag=wx.EXPAND | wx.ALL,
                       border=5)
        # 添加底部sizer,proportion=1 代表bsizer_bottom大小变化
        bsizer_botoom = wx.BoxSizer(wx.HORIZONTAL)
        bsizer_all.Add(bsizer_botoom,
                       proportion=0,
                       flag=wx.EXPAND | wx.ALL,
                       border=5)
        bsizer_botoom.Add(bsizer_botton1,
                          proportion=0,
                          flag=wx.EXPAND | wx.ALL,
                          border=5)
        bsizer_botoom.Add(bsizer_botton2,
                          proportion=0,
                          flag=wx.EXPAND | wx.ALL,
                          border=5)
        bsizer_botoom.Add(bsizer_content,
                          proportion=1,
                          flag=wx.EXPAND | wx.ALL,
                          border=5)
        self.Bind(wx.EVT_BUTTON, self.update, self.bt_FlipHoriz)
        self.Bind(wx.EVT_BUTTON, self.zipweb, self.bt_FlipVert)
        self.Bind(wx.EVT_BUTTON, self.addwrite, self.bt_AddWrite)
        panel.SetSizer(bsizer_all)
Exemplo n.º 18
0
    def __init__(self,
                 frame,
                 title,
                 params,
                 order,
                 helpUrl=None,
                 suppressTitles=True,
                 size=(800, 400),
                 style=_style,
                 editing=False,
                 depends=[],
                 timeout=None,
                 type="Code"):

        # translate title
        localizedTitle = title.replace(' Properties',
                                       _translate(' Properties'))
        wx.Dialog.__init__(self,
                           None,
                           -1,
                           localizedTitle,
                           size=size,
                           style=self._style)
        self.SetTitle(localizedTitle)  # use localized title
        # self.panel = wx.Panel(self)
        self.frame = frame
        self.app = frame.app
        self.helpUrl = helpUrl
        self.params = params  # dict
        self.order = order
        self.title = title
        self.timeout = timeout
        self.warningsDict = {}  # to store warnings for all fields
        self.codeBoxes = {}
        self.tabs = OrderedDict()

        if not editing and 'name' in self.params:
            # then we're adding a new component so ensure a valid name:
            makeValid = self.frame.exp.namespace.makeValid
            self.params['name'].val = makeValid(params['name'].val)

        self.codeNotebook = wx.Notebook(self)
        # in AUI notebook the labels are blurry on retina mac
        #   and the close-tab buttons are hard to kill
        #   self.codeNotebook = aui.AuiNotebook(self)
        # in FlatNoteBook the tab controls (left,right,close) are ugly on mac
        #   and also can't be killed

        openToPage = None
        tabN = -1
        for paramN, paramName in enumerate(self.order):
            param = self.params.get(paramName)
            if paramName == 'name':
                self.nameLabel = wx.StaticText(self, wx.ID_ANY,
                                               _translate(param.label))
                _style = wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB
                self.componentName = wx.TextCtrl(self,
                                                 wx.ID_ANY,
                                                 str(param.val),
                                                 style=_style)
                self.componentName.SetToolTip(
                    wx.ToolTip(_translate(param.hint)))
                self.componentName.SetValidator(validators.NameValidator())
                self.nameOKlabel = wx.StaticText(self,
                                                 -1,
                                                 '',
                                                 style=wx.ALIGN_RIGHT)
                self.nameOKlabel.SetForegroundColour(wx.RED)
            elif paramName == 'Code Type':
                # Create code type choice menu
                _codeTypes = self.params['Code Type'].allowedVals
                _selectedCodeType = self.params['Code Type'].val
                _selectedCodeTypeIndex = _codeTypes.index(_selectedCodeType)
                self.codeTypeMenu = wx.Choice(self, choices=_codeTypes)
                # If user does not have metapensiero but codetype is auto-js, revert to (Py?)
                if not hasMetapensiero and _selectedCodeType.lower(
                ) == 'auto->js':
                    _selectedCodeTypeIndex -= 1
                # Set selection to value stored in self params
                self.codeTypeMenu.SetSelection(_selectedCodeTypeIndex)
                self.codeTypeMenu.Bind(wx.EVT_CHOICE, self.onCodeChoice)
                self.codeTypeName = wx.StaticText(self, wx.ID_ANY,
                                                  _translate(param.label))
            elif paramName == 'disabled':
                # Create bool control to disable/enable component
                self.disableCtrl = wx.CheckBox(self,
                                               wx.ID_ANY,
                                               label=paramName)
                self.disableCtrl.SetValue(bool(param.val))
            else:
                codeType = ["Py",
                            "JS"]["JS"
                                  in paramName]  # Give CodeBox a code type
                tabName = paramName.replace("JS ", "")
                if tabName in self.tabs:
                    _panel = self.tabs[tabName]
                else:
                    _panel = wx.Panel(self.codeNotebook, wx.ID_ANY)
                    _panel.app = self.app
                    self.tabs[tabName] = _panel
                    tabN += 1

                self.codeBoxes[paramName] = CodeBox(_panel,
                                                    wx.ID_ANY,
                                                    pos=wx.DefaultPosition,
                                                    style=0,
                                                    prefs=self.app.prefs,
                                                    params=params,
                                                    codeType=codeType)
                self.codeBoxes[paramName].AddText(param.val)
                self.codeBoxes[paramName].Bind(
                    wx.EVT_KEY_UP, self.onKeyUp)  # For real time translation

                if len(param.val.strip()) and openToPage is None:
                    # index of first non-blank page
                    openToPage = tabN

        if self.helpUrl is not None:
            self.helpButton = wx.Button(self, wx.ID_HELP, _translate(" Help "))
            tip = _translate("Go to online help about this component")
            self.helpButton.SetToolTip(wx.ToolTip(tip))
        self.okButton = wx.Button(self, wx.ID_OK, _translate(" OK "))
        self.okButton.SetDefault()
        self.cancelButton = wx.Button(self, wx.ID_CANCEL,
                                      _translate(" Cancel "))
        self.__do_layout()
        if openToPage is None:
            openToPage = 1
        self.codeNotebook.SetSelection(openToPage)
        self.Update()
        self.Bind(wx.EVT_BUTTON, self.helpButtonHandler, self.helpButton)

        if self.timeout:
            timeout = wx.CallLater(self.timeout, self.onEnter)
            timeout.Start()
        # do show and process return
        ret = self.ShowModal()

        if ret == wx.ID_OK:
            self.checkName()
            self.OK = True
            self.params = self.getParams()  # get new vals from dlg
            self.Validate()
        else:
            self.OK = False
Exemplo n.º 19
0
    file.close()


def save(event):
    file = open(filename.GetValue(), 'w')
    file.write(contents.GetValue())
    file.close


##### 生成窗口
app = wx.App()
win = wx.Frame(None, title="李杨的测试", size=(410, 335))
bkg = wx.Panel(win)

##### 定义按钮
loadButton = wx.Button(bkg, label='打开')
loadButton.Bind(wx.EVT_BUTTON, load)
saveButton = wx.Button(bkg, label='保存')
saveButton.Bind(wx.EVT_BUTTON, save)

##### 定义文本框
filename = wx.TextCtrl(bkg)
contents = wx.TextCtrl(bkg, style=wx.TE_MULTILINE | wx.HSCROLL)

##### 定义组件相对位置
hbox = wx.BoxSizer()
hbox.Add(filename, proportion=1, flag=wx.EXPAND)
hbox.Add(loadButton, proportion=0, flag=wx.LEFT, border=5)
hbox.Add(saveButton, proportion=0, flag=wx.LEFT, border=5)

vbox = wx.BoxSizer(wx.VERTICAL)
Exemplo n.º 20
0
    def __init__(self, parent, id, title, size):
        # 初始化,添加控件并绑定事件
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          style=wx.MINIMIZE_BOX | wx.RESIZE_BORDER
                          | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX
                          | wx.CLIP_CHILDREN)
        self.SetSize(size)
        self.Center()

        try:
            image_file = './37.jpg'
            to_bmp_image = wx.Image(image_file,
                                    wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
            image_width = to_bmp_image.GetWidth()
            image_height = to_bmp_image.GetHeight()
        except IOError:
            print('Image file %s not found' % image_file)
            raise SystemExit

        self.chatFrame = wx.TextCtrl(self.bitmap,
                                     pos=(520, 49),
                                     size=(588, 310),
                                     style=wx.TE_MULTILINE | wx.TE_READONLY)
        self.chatFrame.SetForegroundColour('blue')
        self.chatFrame.SetBackgroundColour('white')
        self.message = wx.TextCtrl(self.bitmap,
                                   pos=(520, 485),
                                   size=(588, 136),
                                   style=wx.TE_PROCESS_ENTER)
        self.sayButton = wx.Button(self.bitmap,
                                   label="语音识别",
                                   pos=(970, 365),
                                   size=(138, 55),
                                   style=wx.STAY_ON_TOP)
        self.sayButton.SetForegroundColour('blue')
        self.sayButton.SetBackgroundColour('white')
        self.screenshotButton = wx.Button(self.bitmap,
                                          label="屏幕截图",
                                          pos=(520, 425),
                                          size=(138, 55))
        self.screenshotButton.SetForegroundColour('blue')
        self.screenshotButton.SetBackgroundColour('white')
        self.searchButton = wx.Button(self.bitmap,
                                      label="百度搜索",
                                      pos=(970, 425),
                                      size=(138, 55))
        self.searchButton.SetForegroundColour('blue')
        self.searchButton.SetBackgroundColour('white')
        self.songButton = wx.Button(self.bitmap,
                                    label="播放音乐",
                                    pos=(820, 425),
                                    size=(138, 55))
        self.songButton.SetForegroundColour('blue')
        self.songButton.SetBackgroundColour('white')
        self.sendButton = wx.Button(self.bitmap,
                                    label="发送消息",
                                    pos=(820, 625),
                                    size=(138, 55))
        self.sendButton.SetForegroundColour('black')
        self.sendButton.SetBackgroundColour('white')
        self.usersButton = wx.Button(self.bitmap,
                                     label="在线用户",
                                     pos=(670, 425),
                                     size=(138, 55))
        self.usersButton.SetForegroundColour('blue')
        self.usersButton.SetBackgroundColour('white')
        self.closeButton = wx.Button(self.bitmap,
                                     label="退出系统",
                                     pos=(970, 625),
                                     size=(138, 55))
        self.closeButton.SetForegroundColour('red')
        self.closeButton.SetBackgroundColour('white')
        self.runButton = wx.Button(self.bitmap,
                                   label="启动机器人",
                                   pos=(520, 365),
                                   size=(138, 55))
        self.runButton.SetForegroundColour('blue')
        self.runButton.SetBackgroundColour('white')
        self.weatherButton = wx.Button(self.bitmap,
                                       label="天气查询",
                                       pos=(670, 365),
                                       size=(138, 55))
        self.weatherButton.SetForegroundColour('blue')
        self.weatherButton.SetBackgroundColour('white')
        self.translateButton = wx.Button(self.bitmap,
                                         label="中英互译",
                                         pos=(820, 365),
                                         size=(138, 55))
        self.translateButton.SetForegroundColour('blue')
        self.translateButton.SetBackgroundColour('white')

        self.sendButton.Bind(wx.EVT_BUTTON, self.send)  # 发送按钮绑定发送消息方法
        self.message.SetFocus()  # 输入框回车焦点
        self.sayButton.Bind(wx.EVT_BUTTON, self.say)  # SAY按钮按下
        self.Bind(wx.EVT_TEXT_ENTER, self.send, self.message)  # 回车发送消息
        self.usersButton.Bind(wx.EVT_BUTTON,
                              self.lookUsers)  # Users按钮绑定获取在线用户数量方法
        self.closeButton.Bind(wx.EVT_BUTTON, self.close)  # 关闭按钮绑定关闭方法
        self.screenshotButton.Bind(wx.EVT_BUTTON, self.screenshot)
        self.songButton.Bind(wx.EVT_BUTTON, self.song)
        self.searchButton.Bind(wx.EVT_BUTTON, self.search)
        self.runButton.Bind(wx.EVT_BUTTON, self.run)
        self.translateButton.Bind(wx.EVT_BUTTON, self.translate)
        self.weatherButton.Bind(wx.EVT_BUTTON, self.weather)
        treceive = threading.Thread(target=self.receive)  # 接收信息线程
        treceive.start()
        #self.ShowFullScreen(True)  # 全屏
        self.Show()
Exemplo n.º 21
0
    def __init__(self, parent):
        wx.Frame.__init__ (self, parent, id = wx.ID_ANY, title = u"Rename Series", pos = wx.DefaultPosition, size = wx.Size(350,420), style = wx.CAPTION | wx.FRAME_FLOAT_ON_PARENT | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        main_sizer = wx.BoxSizer(wx.VERTICAL)

        self.main_panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL)
        self.main_panel.SetBackgroundColour(wx.Colour(219, 219, 219))

        main_panel_sizer = wx.BoxSizer(wx.VERTICAL)

        sub_panel_sizer_1 = wx.FlexGridSizer(2, 2, 0, 0)
        sub_panel_sizer_1.SetFlexibleDirection(wx.BOTH)
        sub_panel_sizer_1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.dataFrame_StaticTxt = wx.StaticText(self.main_panel, wx.ID_ANY, u"DataFrame: ", wx.DefaultPosition, wx.DefaultSize, 0)
        self.dataFrame_StaticTxt.Wrap(-1)
        sub_panel_sizer_1.Add(self.dataFrame_StaticTxt, 0, wx.ALL, 5)

        dataFrame_ChoiceBoxChoices = []
        self.dataFrame_ChoiceBox = wx.Choice(self.main_panel, wx.ID_ANY, wx.DefaultPosition, wx.Size(225,-1), dataFrame_ChoiceBoxChoices, 0)
        self.dataFrame_ChoiceBox.SetSelection(0)
        sub_panel_sizer_1.Add(self.dataFrame_ChoiceBox, 0, wx.ALL, 5)

        self.Series_StaticsTxt = wx.StaticText(self.main_panel, wx.ID_ANY, u"Series: ", wx.DefaultPosition, wx.DefaultSize, 0)
        self.Series_StaticsTxt.Wrap(-1)
        sub_panel_sizer_1.Add(self.Series_StaticsTxt, 0, wx.ALL, 5)

        Series_ListBoxChoices = []
        self.Series_ListBox = wx.ListBox(self.main_panel, wx.ID_ANY, wx.DefaultPosition, wx.Size(225,-1), Series_ListBoxChoices, wx.LB_EXTENDED | wx.LB_HSCROLL)
        sub_panel_sizer_1.Add(self.Series_ListBox, 0, wx.ALL | wx.EXPAND, 5)

        main_panel_sizer.Add(sub_panel_sizer_1, 0, wx.ALL | wx.EXPAND, 5)

        sub_panel_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)

        self.add_button = wx.Button(self.main_panel, wx.ID_ANY, u"Add...", wx.DefaultPosition, wx.DefaultSize, 0)
        sub_panel_sizer_2.Add(self.add_button, 0, wx.ALL, 5)

        main_panel_sizer.Add(sub_panel_sizer_2, 0, wx.ALIGN_CENTER, 5)

        sub_panel_sizer_3 = wx.BoxSizer(wx.VERTICAL)

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

        self.current_name_StaticText = wx.StaticText(self.main_panel, wx.ID_ANY, u"Current Name: ", wx.DefaultPosition, wx.DefaultSize, 0)
        self.current_name_StaticText.Wrap(-1)
        panel_grid_sizer.Add(self.current_name_StaticText, 0, wx.ALL, 5)

        self.new_name_StaticText = wx.StaticText(self.main_panel, wx.ID_ANY, u"New Name:", wx.DefaultPosition, wx.DefaultSize, 0)
        self.new_name_StaticText.Wrap(-1)
        panel_grid_sizer.Add(self.new_name_StaticText, 0, wx.ALL, 5)

        self.current_name_TxtCtrl_1 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL | wx.TE_READONLY)
        panel_grid_sizer.Add(self.current_name_TxtCtrl_1, 0, wx.ALL, 5)

        self.new_name_TxtCtrl_1 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL)
        panel_grid_sizer.Add(self.new_name_TxtCtrl_1, 0, wx.ALL, 5)

        self.current_name_TxtCtrl_2 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL | wx.TE_READONLY)
        panel_grid_sizer.Add(self.current_name_TxtCtrl_2, 0, wx.ALL, 5)

        self.new_name_TxtCtrl_2 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL)
        panel_grid_sizer.Add(self.new_name_TxtCtrl_2, 0, wx.ALL, 5)

        self.current_name_TxtCtrl_3 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL | wx.TE_READONLY)
        panel_grid_sizer.Add(self.current_name_TxtCtrl_3, 0, wx.ALL, 5)

        self.new_name_TxtCtrl_3 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL)
        panel_grid_sizer.Add(self.new_name_TxtCtrl_3, 0, wx.ALL, 5)

        self.current_name_TxtCtrl_4 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL | wx.TE_READONLY)
        panel_grid_sizer.Add(self.current_name_TxtCtrl_4, 0, wx.ALL, 5)

        self.new_name_TxtCtrl_4 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL)
        panel_grid_sizer.Add(self.new_name_TxtCtrl_4, 0, wx.ALL, 5)

        self.current_name_TxtCtrl_5 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL | wx.TE_READONLY)
        panel_grid_sizer.Add(self.current_name_TxtCtrl_5, 0, wx.ALL, 5)

        self.new_name_TxtCtrl_5 = wx.TextCtrl(self.main_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(150,-1), wx.HSCROLL)
        panel_grid_sizer.Add(self.new_name_TxtCtrl_5, 0, wx.ALL, 5)

        sub_panel_sizer_3.Add(panel_grid_sizer, 0, wx.ALL | wx.EXPAND, 5)

        m_sdbSizer3 = wx.StdDialogButtonSizer()
        self.m_sdbSizer3OK = wx.Button(self.main_panel, wx.ID_OK)
        m_sdbSizer3.AddButton(self.m_sdbSizer3OK)
        self.m_sdbSizer3Cancel = wx.Button(self.main_panel, wx.ID_CANCEL)
        m_sdbSizer3.AddButton(self.m_sdbSizer3Cancel)
        m_sdbSizer3.Realize()
        sub_panel_sizer_3.Add(m_sdbSizer3, 1, wx.ALL | wx.EXPAND, 5)

        main_panel_sizer.Add(sub_panel_sizer_3, 0, wx.EXPAND, 5)

        self.main_panel.SetSizer(main_panel_sizer)
        self.main_panel.Layout()
        main_panel_sizer.Fit(self.main_panel)
        main_sizer.Add(self.main_panel, 1, wx.EXPAND, 5)

        self.SetSizer(main_sizer)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.dataFrame_ChoiceBox.Bind(wx.EVT_CHOICE, self.on_dataFrame_choice)
        self.Series_ListBox.Bind(wx.EVT_LISTBOX, self.on_series_selections)
        self.add_button.Bind(wx.EVT_BUTTON, self.add_selections_to_gui)
        self.m_sdbSizer3Cancel.Bind(wx.EVT_BUTTON, self.on_cancel)
        self.m_sdbSizer3OK.Bind(wx.EVT_BUTTON, self.on_ok)
Exemplo n.º 22
0
    def __init__(self, parent, id, title, size):
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          style=wx.MINIMIZE_BOX | wx.RESIZE_BORDER
                          | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX
                          | wx.CLIP_CHILDREN)

        try:
            image_file = './111.png'
            to_bmp_image = wx.Image(image_file,
                                    wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
            image_width = to_bmp_image.GetWidth()
            image_height = to_bmp_image.GetHeight()
        except IOError:
            print('Image file %s not found' % image_file)
            raise SystemExit

        self.SetSize(size)
        self.Center()
        self.serverAddressLabel = wx.Button(
            self.bitmap,
            -1,
            label="服务器",
            pos=(680, 165),
            size=(130, 33),
        )
        self.serverAddressLabel.SetForegroundColour('blue')
        self.userNameLabel = wx.Button(self.bitmap,
                                       -1,
                                       label="用户名",
                                       pos=(680, 230),
                                       size=(130, 33))
        self.userNameLabel.SetForegroundColour('blue')
        self.serverAddress = wx.TextCtrl(self.bitmap,
                                         -1,
                                         value=default_server,
                                         pos=(820, 165),
                                         size=(150, 30),
                                         style=wx.TE_PROCESS_ENTER)
        self.serverAddress.SetForegroundColour('blue')
        self.userName = wx.TextCtrl(self.bitmap,
                                    -1,
                                    pos=(820, 230),
                                    size=(150, 30),
                                    style=wx.TE_PROCESS_ENTER)
        self.userName.SetForegroundColour('blue')
        self.loginButton = wx.Button(self.bitmap,
                                     -1,
                                     label='登录',
                                     pos=(690, 300),
                                     size=(120, 45))

        self.loginButton.SetForegroundColour('blue')
        # self.loginButton.SetBackgroundColour('green')
        self.exitButton = wx.Button(self.bitmap,
                                    -1,
                                    label='退出',
                                    pos=(840, 300),
                                    size=(120, 45))
        self.exitButton.SetForegroundColour('red')
        # panel.SetSizer(sizer)
        # panel.Fit()
        # 绑定登录方法
        self.loginButton.Bind(wx.EVT_BUTTON, self.login)
        # 绑定退出方法
        self.exitButton.Bind(wx.EVT_BUTTON, self.exit)
        # 服务器输入框Tab事件
        self.serverAddress.SetFocus()
        self.Bind(wx.EVT_TEXT_ENTER, self.usn_focus, self.serverAddress)
        # 用户名回车登录
        self.Bind(wx.EVT_TEXT_ENTER, self.login, self.userName)
        self.Show()
Exemplo n.º 23
0
    def __init__(self, *args, **kwargs):
        super(gui, self).__init__(*args, **kwargs)

        self.SetSize((560, 640))
        self.SetTitle('recipe generator')
        self.Centre()

        menubar = wx.MenuBar()
        fileMenu = wx.Menu()

        qmi = wx.MenuItem(fileMenu, wx.ID_CLOSE, '&quit\tCtrl+Q')
        fileMenu.Append(qmi)
        self.Bind(wx.EVT_MENU, self.quit, id=wx.ID_CLOSE)

        imi = wx.MenuItem(fileMenu, -1, '&import (source)\tCtrl+I')
        fileMenu.Append(imi)
        self.Bind(wx.EVT_MENU, self.onimport, imi)
        omi = wx.MenuItem(fileMenu, -1, '&open (destination)\tCtrl+O')
        fileMenu.Append(omi)
        self.Bind(wx.EVT_MENU, self.open, omi)

        rmi = wx.MenuItem(fileMenu, 3, '&reset all recipes')
        fileMenu.Append(rmi)
        self.Bind(wx.EVT_MENU, self.reset, id=3)

        menubar.Append(fileMenu, '&File')
        self.SetMenuBar(menubar)

        panel = wx.Panel(self)

        icon = wx.Icon()
        icon.CopyFromBitmap(wx.Bitmap("icon.ico", wx.BITMAP_TYPE_ICO))
        self.SetIcon(icon)

        wx.StaticText(panel,
                      -1,
                      label='source path:',
                      pos=(20, 0),
                      size=(500, 20))
        self.input = wx.TextCtrl(panel,
                                 -1,
                                 value='[path to your recipes datapack]',
                                 pos=(20, 20),
                                 size=(500, 40),
                                 style=wx.TE_MULTILINE)

        wx.StaticText(panel,
                      -1,
                      label='destination path:',
                      pos=(20, 60),
                      size=(500, 20))
        self.output = wx.TextCtrl(
            panel,
            -1,
            value='[path to your newly created datapack folder]',
            pos=(20, 80),
            size=(500, 40),
            style=wx.TE_MULTILINE)

        panel.Bind(
            wx.EVT_BUTTON, self.generate,
            wx.Button(panel,
                      -1,
                      label='generate reicpes',
                      pos=(200, 140),
                      size=(160, 40)))

        wx.StaticText(panel, -1, label='log:', pos=(20, 180), size=(500, 20))
        self.log = wx.TextCtrl(
            panel,
            -1,
            value=
            f'[generator opened at {time.now().strftime("%Y-%m-%d %H:%M:%S")}]',
            pos=(20, 200),
            size=(500, 260),
            style=wx.TE_MULTILINE | wx.TE_READONLY)

        self.Bind(wx.EVT_CLOSE, self.quit, self)
Exemplo n.º 24
0
    def __init__(self, *args, **kwds):
        atexit.register(self.exit_handler)

        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE | wx.TAB_TRAVERSAL
        wx.Frame.__init__(self, *args, **kwds)
        self.SetTitle("fattureCCSR")

        self._initial_locale = wx.Locale(wx.LANGUAGE_DEFAULT, wx.LOCALE_LOAD_DEFAULT)

        self.input_files = list()
        self.log_dialog = None
        self.session = requests.Session()

        self.panel = wx.Panel(self, wx.ID_ANY, style=wx.BORDER_NONE | wx.FULL_REPAINT_ON_RESIZE | wx.TAB_TRAVERSAL)
        self.main_sizer = wx.BoxSizer(wx.VERTICAL)

        title_lbl = wx.StaticText(self.panel, wx.ID_ANY, "Utility Fatture Casa di Cura San Rossore")
        title_lbl.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, 0, ""))
        self.main_sizer.Add(title_lbl, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 2)

        desc_lbl = wx.StaticText(self.panel, wx.ID_ANY, "Effettua il login poi seleziona le date di inizio e fine periodo delle fatture da gestire ed esegui un'azione")
        self.main_sizer.Add(desc_lbl, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 2)

        self.login_dlg = LoginDialog(self)
        self.output_traf2000_dialog = wx.FileDialog(self.panel, "Scegli dove salvare il file TRAF2000", defaultFile="TRAF2000", style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
        self.output_pdf_dialog = wx.FileDialog(self.panel, "Scegli dove salvare il .pdf con le fatture scaricate", defaultFile="fatture.pdf", style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)

        self.login_btn = wx.Button(self.panel, LOGIN_ACTION, "Login")
        self.login_btn.SetFocus()
        self.login_btn.Bind(wx.EVT_BUTTON, self.btn_onclick)
        self.main_sizer.Add(self.login_btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 2)

        self.logout_btn = wx.Button(self.panel, LOGOUT_ACTION, "Logout")
        self.logout_btn.Hide()
        self.logout_btn.Bind(wx.EVT_BUTTON, self.btn_onclick)
        self.main_sizer.Add(self.logout_btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 2)

        date_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.main_sizer.Add(date_sizer, 0, wx.ALL | wx.EXPAND, 2)

        start_date_lbl = wx.StaticText(self.panel, wx.ID_ANY, "Dal")
        date_sizer.Add(start_date_lbl, 0, wx.ALL, 2)

        self.start_date_picker = wx.adv.DatePickerCtrl(self.panel, wx.ID_ANY, dt=wx.DateTime.Today().SetDay(1))
        self.start_date_picker.Enable(False)
        date_sizer.Add(self.start_date_picker, 1, wx.ALL, 2)

        end_date_lbl = wx.StaticText(self.panel, wx.ID_ANY, "Al")
        date_sizer.Add(end_date_lbl, 0, wx.ALL, 2)

        self.end_date_picker = wx.adv.DatePickerCtrl(self.panel, wx.ID_ANY, dt=wx.DateTime.Today())
        self.end_date_picker.Enable(False)
        date_sizer.Add(self.end_date_picker, 1, wx.ALL, 2)

        action_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.main_sizer.Add(action_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 2)

        self.download_btn = wx.Button(self.panel, DOWNLOAD_ACTION, "Scarica Fatture")
        self.download_btn.Enable(False)
        self.download_btn.Bind(wx.EVT_BUTTON, self.btn_onclick)
        action_sizer.Add(self.download_btn, 0, wx.ALL, 2)

        self.traf2000_btn = wx.Button(self.panel, CONVERT_ACTION, "Genera TRAF2000")
        self.traf2000_btn.Enable(False)
        self.traf2000_btn.Bind(wx.EVT_BUTTON, self.btn_onclick)
        action_sizer.Add(self.traf2000_btn, 0, wx.ALL, 2)

        self.panel.SetSizer(self.main_sizer)

        self.main_sizer.Fit(self)
        self.Layout()
        self.Centre()
Exemplo n.º 25
0
	def CreateButton(self,parent,label):
		self.Button =wx.Button(parent,label=label)
		self.Button.SetForegroundColour('#FFFFFF')
		self.Button.SetBackgroundColour('#32506D') 
		return self.Button
Exemplo n.º 26
0
 board = wx.Panel(panel, -1, size=(100, 100))
 Butzone = wx.Panel(panel, -1, size=(600, 1000))
 player = [Player('white'), Player('black')]
 field = Field(board, player)
 bot = ReversiBot('white')
 nowColor = 'black'
 crossnum = 0
 sleeps = 0
 passFlag = False
 Flag = False
 TurnTimer = wx.Timer(frame, id=195)
 timer = wx.Timer(frame, id=196)
 ChangeColorTimer = wx.Timer(frame, id=197)
 ButtonFont = wx.Font(30, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                      wx.FONTWEIGHT_NORMAL)
 PassButton = wx.Button(Butzone, 198, 'Pass')
 PassButton.SetFont(ButtonFont)
 ResetButton = wx.Button(Butzone, 199, 'Restart')
 ResetButton.SetFont(ButtonFont)
 sizer2 = wx.BoxSizer(wx.VERTICAL)
 sizer2.Add(PassButton, flag=wx.GROW | wx.RIGHT)
 sizer2.Add(ResetButton, flag=wx.GROW | wx.RIGHT)
 Ranking = SetRanking(sizer2)
 RankList = LoadRanking()
 Butzone.SetSizer(sizer2)
 sizer.Add(board, 10, flag=wx.SHAPED)
 sizer.Add(Butzone, 1)
 panel.SetSizer(sizer)
 frame.Bind(wx.EVT_BUTTON, ButtonPush)
 frame.Bind(wx.EVT_TIMER, update)
 frame.Show()
Exemplo n.º 27
0
    def __init__(self, set_new_users, make_freq_requests, release_freq,
                 set_emphasis, get_freq_data, get_user_data, get_geoloc_data):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'SDR HQ',
                          size=(700, 600),
                          style=wx.DEFAULT_FRAME_STYLE)

        self.panels = {}
        self.ids = {}

        self.users = []
        self.freq_data = []

        self.main_panel_start = True

        self.timer = wx.Timer(self, -1)
        self.timer.Start(1000)

        self.lock = threading.Lock()

        #Menus
        ##########################################################################
        menubar = wx.MenuBar()

        file_menu = wx.Menu()
        quit_action = wx.MenuItem(file_menu, -1, '&Quit\tCtrl+Q')
        file_menu.AppendItem(quit_action)

        dsa_menu = wx.Menu()
        spectrum_action = wx.MenuItem(dsa_menu, -1,
                                      "View &Spectral Use\tCtrl+S")
        manage_action = wx.MenuItem(dsa_menu, -1, "&Manage Spectrum\tCtrl+M")
        graphic_action = wx.MenuItem(dsa_menu, -1, "&Graphic Spectrum\tCtrl+G")

        dsa_menu.AppendItem(spectrum_action)
        dsa_menu.AppendItem(manage_action)
        dsa_menu.AppendItem(graphic_action)

        user_menu = wx.Menu()
        new_action = wx.MenuItem(user_menu, -1, "&Add New User\tCtrl+A")
        current_action = wx.MenuItem(user_menu, -1,
                                     "View Current &Users\tCtrl+U")

        user_menu.AppendItem(new_action)
        user_menu.AppendItem(current_action)

        help_menu = wx.Menu()
        about_action = wx.MenuItem(help_menu, -1, '&About\tCtrl+B')
        demo_action = wx.MenuItem(help_menu, -1, '&Demo\tCtrl+D')
        al_action = wx.MenuItem(help_menu, -1, 'A&l\tCtrl+L')

        help_menu.AppendItem(about_action)
        help_menu.AppendItem(demo_action)
        help_menu.AppendItem(al_action)

        menubar.Append(file_menu, '&File')
        menubar.Append(dsa_menu, '&DSA')
        menubar.Append(user_menu, '&User')
        menubar.Append(help_menu, '&Help')

        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU, self.quit, id=quit_action.GetId())
        self.Bind(wx.EVT_MENU, self.panel_show, id=spectrum_action.GetId())
        self.Bind(wx.EVT_MENU, self.panel_show, id=manage_action.GetId())
        self.Bind(wx.EVT_MENU, self.panel_show, id=graphic_action.GetId())
        self.Bind(wx.EVT_MENU, self.panel_show, id=new_action.GetId())
        self.Bind(wx.EVT_MENU, self.panel_show, id=current_action.GetId())
        self.Bind(wx.EVT_MENU, self.about_handler, id=about_action.GetId())
        self.Bind(wx.EVT_MENU, self.demo, id=demo_action.GetId())
        self.Bind(wx.EVT_MENU, self.al_handler, id=al_action.GetId())

        #Main Panel
        ##########################################################################
        main_panel = wx.Panel(self, -1)

        main_tag = wx.StaticText(main_panel, -1, 'Welcome to the SDR09 GUI')
        main_tag_font = main_tag.GetFont()
        main_tag_font.SetWeight(wx.FONTWEIGHT_BOLD)
        main_tag_font.SetDefaultEncoding(wx.FONTENCODING_DEFAULT)
        main_tag_font.SetFamily(wx.FONTFAMILY_DECORATIVE)
        main_tag_font.SetPointSize(32)
        main_tag.SetFont(main_tag_font)

        main_subtag = wx.StaticText(main_panel, -1,
                                    "What should the subtag say?")
        main_subtag_font = main_subtag.GetFont()
        main_subtag_font.SetDefaultEncoding(wx.FONTENCODING_DEFAULT)
        main_subtag_font.SetFamily(wx.FONTFAMILY_DECORATIVE)
        main_subtag_font.SetPointSize(28)
        main_subtag.SetFont(main_subtag_font)

        main_demo_button = wx.Button(main_panel, -1, "Demo")
        main_demo_button_font = main_demo_button.GetFont()
        main_demo_button_font.SetEncoding(wx.FONTENCODING_DEFAULT)
        main_demo_button_font.SetFamily(wx.FONTFAMILY_DECORATIVE)
        main_demo_button_font.SetPointSize(28)
        main_demo_button.SetFont(main_demo_button_font)

        main_box = wx.GridSizer(3, 2, 2, 2)

        main_box.Add(main_tag, 0, wx.ALIGN_CENTER | wx.ALL, 15)
        main_box.Add(wx.Size(0, 200), 0)
        main_box.Add(main_subtag, 0, wx.ALIGN_CENTER | wx.ALL, 15)
        main_box.Add(wx.Size(0, 100), 0)
        main_box.Add(main_demo_button, 0, wx.ALIGN_CENTER | wx.ALL, 15)
        main_box.Add(wx.Size(0, 100), 0)

        main_panel.SetSizer(main_box)

        main_panel.Bind(wx.EVT_BUTTON, self.demo, id=main_demo_button.GetId())

        main_panel.Show(self.main_panel_start)

        self.panels[-1] = main_panel

        #Spectrum Panel
        ##########################################################################
        spectrum_panel = wx.Panel(self, -1)

        spectrum_tag = wx.StaticText(spectrum_panel, -1, "Spectral Use")
        spectrum_tag_font = spectrum_tag.GetFont()
        spectrum_tag_font.SetPointSize(16)
        spectrum_tag.SetFont(spectrum_tag_font)

        spectrum_box1 = wx.BoxSizer(wx.VERTICAL)
        spectrum_box2 = wx.FlexGridSizer(15, 3, 2, 2)

        spectrum_freq_label = wx.StaticText(spectrum_panel, -1,
                                            "Center Frequency")
        spectrum_user_label = wx.StaticText(spectrum_panel, -1,
                                            "Occuping User")
        spectrum_time_label = wx.StaticText(spectrum_panel, -1,
                                            "Timeout Value")

        spectrum_freq_label_font = spectrum_freq_label.GetFont()
        spectrum_freq_label_font.SetPointSize(12)
        spectrum_freq_label.SetFont(spectrum_freq_label_font)

        spectrum_user_label_font = spectrum_user_label.GetFont()
        spectrum_user_label_font.SetPointSize(12)
        spectrum_user_label.SetFont(spectrum_user_label_font)

        spectrum_time_label_font = spectrum_time_label.GetFont()
        spectrum_time_label_font.SetPointSize(12)
        spectrum_time_label.SetFont(spectrum_time_label_font)

        spectrum_box2.Add(spectrum_freq_label, 0, wx.ALIGN_CENTER, 0)
        spectrum_box2.Add(spectrum_user_label, 0, wx.ALIGN_CENTER, 0)
        spectrum_box2.Add(spectrum_time_label, 0, wx.ALIGN_CENTER, 0)

        self.spectrum_ctrl = []
        for i in range(14):
            tmp = {}
            tmp['freq'] = wx.TextCtrl(spectrum_panel,
                                      -1,
                                      '',
                                      style=wx.TE_READONLY | wx.TE_CENTER)
            tmp['user'] = wx.TextCtrl(spectrum_panel,
                                      -1,
                                      '',
                                      style=wx.TE_READONLY | wx.TE_CENTER)
            tmp['time'] = wx.TextCtrl(spectrum_panel,
                                      -1,
                                      '',
                                      style=wx.TE_READONLY | wx.TE_CENTER)

            spectrum_box2.Add(tmp['freq'], 0, wx.EXPAND, 0)
            spectrum_box2.Add(tmp['user'], 0, wx.EXPAND, 0)
            spectrum_box2.Add(tmp['time'], 0, wx.EXPAND, 0)

            self.spectrum_ctrl.append(tmp)

        spectrum_space = 225
        spectrum_box2.Add(wx.Size(spectrum_space, 0), 0)
        spectrum_box2.Add(wx.Size(spectrum_space, 0), 0)
        spectrum_box2.Add(wx.Size(spectrum_space, 0), 0)

        spectrum_box1.Add(spectrum_tag, 0, wx.ALL, 0)
        spectrum_box1.Add(wx.Size(0, 25), 0)
        spectrum_box1.Add(spectrum_box2, 0, wx.EXPAND | wx.ALL, 7)

        spectrum_panel.SetSizer(spectrum_box1)

        spectrum_panel.Show(not (self.main_panel_start))

        self.panels[spectrum_action.GetId()] = spectrum_panel

        #Graphic Panel
        ##########################################################################
        graphic_panel = wx.Panel(self, -1)

        graphic_tag = wx.StaticText(graphic_panel, -1,
                                    'Graphical Spectrum View')
        graphic_tag_font = graphic_tag.GetFont()
        graphic_tag_font.SetPointSize(16)
        graphic_tag.SetFont(graphic_tag_font)

        graphic_box2 = wx.FlexGridSizer(5, 5, 4, 4)
        graphic_vert_space = 100
        graphic_hori_space = 169

        self.graphic_ctrl = []
        j = 0
        for i in range(15):
            if j < 4:
                tmp = colored_text_box(graphic_panel, '')
                graphic_box2.Add(tmp, 0, wx.EXPAND | wx.ALIGN_CENTER, 0)
                self.graphic_ctrl.append(tmp)
                j += 1
            else:
                j = 0
                graphic_box2.Add(wx.Size(0, graphic_vert_space), 0)

        graphic_box2.Add(wx.Size(0, 0), 0)

        tmp = colored_text_box(graphic_panel, '')
        graphic_box2.Add(tmp, 0, wx.EXPAND | wx.ALIGN_CENTER, 0)
        self.graphic_ctrl.append(tmp)

        tmp = colored_text_box(graphic_panel, '')
        graphic_box2.Add(tmp, 0, wx.EXPAND | wx.ALIGN_CENTER, 0)
        self.graphic_ctrl.append(tmp)

        graphic_box2.Add(wx.Size(0, graphic_vert_space), 0)
        graphic_box2.Add(wx.Size(0, 0), 0)

        graphic_box2.Add(wx.Size(graphic_hori_space, 0), 0)
        graphic_box2.Add(wx.Size(graphic_hori_space, 0), 0)
        graphic_box2.Add(wx.Size(graphic_hori_space, 0), 0)
        graphic_box2.Add(wx.Size(graphic_hori_space, 0), 0)
        graphic_box2.Add(wx.Size(0, 0), 0)

        graphic_box1 = wx.BoxSizer(wx.VERTICAL)

        graphic_box1.Add(graphic_tag, 0, wx.ALL, 5)
        graphic_box1.Add(wx.Size(0, 25), 0)
        graphic_box1.Add(graphic_box2, 0, wx.EXPAND | wx.ALL, 5)

        graphic_panel.SetSizer(graphic_box1)

        graphic_panel.Show(False)

        self.panels[graphic_action.GetId()] = graphic_panel

        #Manage Panel
        ##########################################################################
        manage_panel = wx.Panel(self, -1)

        manage_request_tag = wx.StaticText(manage_panel, -1,
                                           "Request Frequency")
        manage_request_label = wx.StaticText(manage_panel, -1,
                                             "Enter Id of Requesting Team:")
        self.manage_request_ctrl = wx.TextCtrl(manage_panel,
                                               -1,
                                               '',
                                               style=wx.TE_PROCESS_ENTER)
        manage_request_button = wx.Button(manage_panel, -1, "Submit Request")

        manage_release_tag = wx.StaticText(manage_panel, -1,
                                           "Release Frequency")
        manage_release_label = wx.StaticText(manage_panel, -1,
                                             "Enter Frequency to Release:")
        self.manage_release_ctrl = wx.TextCtrl(manage_panel,
                                               -1,
                                               '',
                                               style=wx.TE_PROCESS_ENTER)
        manage_release_button = wx.Button(manage_panel, -1, "Submit Release")

        manage_emphasis_tag = wx.StaticText(manage_panel, -1,
                                            "Set Skill Emphasis")
        manage_emphasis_label = wx.StaticText(manage_panel, -1,
                                              "Enter Emphasis:")
        self.manage_emphasis_ctrl = wx.TextCtrl(manage_panel,
                                                -1,
                                                '',
                                                style=wx.TE_PROCESS_ENTER)
        manage_emphasis_button = wx.Button(manage_panel, -1, "Set Emphasis")

        manage_tag_font = manage_request_tag.GetFont()
        manage_tag_font.SetPointSize(16)
        manage_tag_font.SetUnderlined(True)

        manage_request_tag.SetFont(manage_tag_font)
        manage_release_tag.SetFont(manage_tag_font)
        manage_emphasis_tag.SetFont(manage_tag_font)

        manage_label_font = manage_request_label.GetFont()
        manage_label_font.SetPointSize(12)

        manage_request_label.SetFont(manage_label_font)
        manage_release_label.SetFont(manage_label_font)
        manage_emphasis_label.SetFont(manage_label_font)

        manage_front_space = 5

        manage_box = wx.FlexGridSizer(10, 5, 4, 4)

        manage_box.Add(wx.Size(0, 50), 0)
        manage_box.Add(wx.Size(225, 0), 0)
        manage_box.Add(wx.Size(250, 0), 0)
        manage_box.Add(wx.Size(200, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(manage_front_space, 0), 0)
        manage_box.Add(manage_request_tag, 0, wx.ALL, 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(manage_front_space, 0), 20)
        manage_box.Add(manage_request_label, 0, wx.ALIGN_CENTER, 0)
        manage_box.Add(self.manage_request_ctrl, 0, wx.EXPAND, 0)
        manage_box.Add(manage_request_button, 0, wx.EXPAND | wx.ALL, 2)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(0, 75), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(manage_front_space, 0), 0)
        manage_box.Add(manage_release_tag, 0, wx.ALL, 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(manage_front_space, 0), 20)
        manage_box.Add(manage_release_label, 0, wx.ALIGN_CENTER, 0)
        manage_box.Add(self.manage_release_ctrl, 0, wx.EXPAND, 0)
        manage_box.Add(manage_release_button, 0, wx.EXPAND | wx.ALL, 2)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(0, 75), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(manage_front_space, 0), 0)
        manage_box.Add(manage_emphasis_tag, 0, wx.ALL, 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(manage_front_space, 0), 20)
        manage_box.Add(manage_emphasis_label, 0, wx.ALIGN_CENTER, 0)
        manage_box.Add(self.manage_emphasis_ctrl, 1, wx.EXPAND, 0)
        manage_box.Add(manage_emphasis_button, 0, wx.EXPAND | wx.ALL, 2)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_box.Add(wx.Size(0, 50), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)
        manage_box.Add(wx.Size(0, 0), 0)

        manage_panel.SetSizer(manage_box)

        manage_panel.Bind(wx.EVT_BUTTON,
                          self.request_frequency,
                          id=manage_request_button.GetId())
        manage_panel.Bind(wx.EVT_TEXT_ENTER,
                          self.request_frequency,
                          id=self.manage_request_ctrl.GetId())

        manage_panel.Bind(wx.EVT_BUTTON,
                          self.release_frequency,
                          id=manage_release_button.GetId())
        manage_panel.Bind(wx.EVT_TEXT_ENTER,
                          self.release_frequency,
                          id=self.manage_release_ctrl.GetId())

        manage_panel.Bind(wx.EVT_BUTTON,
                          self.set_emphasis,
                          id=manage_emphasis_button.GetId())
        manage_panel.Bind(wx.EVT_TEXT_ENTER,
                          self.set_emphasis,
                          id=self.manage_emphasis_ctrl.GetId())

        manage_panel.Show(False)

        self.panels[manage_action.GetId()] = manage_panel

        #New Panel (New User Panel)
        ##########################################################################
        new_panel = wx.Panel(self, -1)

        new_tag = wx.StaticText(new_panel, -1, "Add New User")

        new_name_label = wx.StaticText(new_panel, -1, "Enter Team Name:")
        self.new_name_ctrl = wx.TextCtrl(new_panel,
                                         -1,
                                         '',
                                         style=wx.TE_PROCESS_ENTER)

        new_skill_label = wx.StaticText(new_panel, -1, "Enter Team Skill:")
        self.new_skill_ctrl = wx.TextCtrl(new_panel,
                                          -1,
                                          '',
                                          style=wx.TE_PROCESS_ENTER)

        new_id_label = wx.StaticText(new_panel, -1, "Team Id:")
        self.new_id_ctrl = wx.TextCtrl(new_panel,
                                       -1,
                                       '1',
                                       style=wx.TE_READONLY)

        self.new_notification_label = wx.StaticText(new_panel,
                                                    -1,
                                                    '',
                                                    style=wx.ALIGN_CENTER)
        new_button = wx.Button(new_panel, -1, "Add User")

        new_tag_font = new_tag.GetFont()
        new_tag_font.SetPointSize(16)
        new_tag.SetFont(new_tag_font)

        label_font = new_name_label.GetFont()
        label_font.SetPointSize(12)

        new_name_label.SetFont(label_font)
        new_skill_label.SetFont(label_font)
        new_id_label.SetFont(label_font)

        self.new_notification_label.SetFont(label_font)
        new_button.SetFont(label_font)

        new_box = wx.FlexGridSizer(9, 3, 0, 0)

        new_box.Add(new_tag, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        new_box.Add(wx.Size(350, 50), 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(wx.Size(300, 75), 0)
        new_box.Add(wx.Size(0, 0), 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(new_name_label, 0, wx.ALIGN_CENTER, 0)
        new_box.Add(self.new_name_ctrl, 0, wx.EXPAND, 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(wx.Size(0, 60), 0)
        new_box.Add(wx.Size(0, 0), 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(new_skill_label, 0, wx.ALIGN_CENTER, 0)
        new_box.Add(self.new_skill_ctrl, 0, wx.EXPAND, 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(wx.Size(0, 60), 0)
        new_box.Add(wx.Size(0, 0), 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(new_id_label, 0, wx.ALIGN_CENTER, 0)
        new_box.Add(self.new_id_ctrl, 0, wx.EXPAND, 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(wx.Size(0, 50), 0)
        new_box.Add(wx.Size(0, 0), 0)
        new_box.Add(wx.Size(0, 0), 0)

        new_box.Add(self.new_notification_label, 0, wx.ALIGN_CENTER, 0)
        new_box.Add(new_button, 0, wx.EXPAND | wx.ALL, 80)
        new_box.Add(wx.Size(0, 250), 0)

        new_panel.SetSizer(new_box)

        new_panel.Bind(wx.EVT_BUTTON, self.add_user, id=new_button.GetId())
        new_panel.Bind(wx.EVT_TEXT_ENTER,
                       self.add_user,
                       id=self.new_name_ctrl.GetId())
        new_panel.Bind(wx.EVT_TEXT_ENTER,
                       self.add_user,
                       id=self.new_skill_ctrl.GetId())
        new_panel.Bind(wx.EVT_TEXT,
                       self.clear_new_notification,
                       id=self.new_name_ctrl.GetId())
        new_panel.Bind(wx.EVT_TEXT,
                       self.clear_new_notification,
                       id=self.new_skill_ctrl.GetId())

        new_panel.Show(False)

        self.panels[new_action.GetId()] = new_panel

        #Current Panel (Current User Panel)
        ##########################################################################
        current_panel = wx.Panel(self, -1)

        current_box = wx.FlexGridSizer(22, 5, 1, 1)

        current_name_label = wx.StaticText(current_panel, -1, 'Name')
        current_id_label = wx.StaticText(current_panel, -1, 'Id')
        current_skill_label = wx.StaticText(current_panel, -1, 'Skill')
        current_lat_label = wx.StaticText(current_panel, -1, 'Latitude')
        current_lon_label = wx.StaticText(current_panel, -1, 'Longitude')

        label_font = current_name_label.GetFont()
        label_font.SetPointSize(12)

        current_name_label.SetFont(label_font)
        current_id_label.SetFont(label_font)
        current_skill_label.SetFont(label_font)
        current_lat_label.SetFont(label_font)
        current_lon_label.SetFont(label_font)

        current_box.Add(current_name_label, 0, wx.ALIGN_CENTER, 0)
        current_box.Add(current_id_label, 0, wx.ALIGN_CENTER, 0)
        current_box.Add(current_skill_label, 0, wx.ALIGN_CENTER, 0)
        current_box.Add(current_lat_label, 0, wx.ALIGN_CENTER, 0)
        current_box.Add(current_lon_label, 0, wx.ALIGN_CENTER, 0)

        self.current_ctrl = []
        for i in range(20):
            tmp = {}
            tmp['name'] = wx.TextCtrl(current_panel,
                                      -1,
                                      '',
                                      style=wx.TE_READONLY | wx.TE_CENTER)
            tmp['id'] = wx.TextCtrl(current_panel,
                                    -1,
                                    '',
                                    style=wx.TE_READONLY | wx.TE_CENTER)
            tmp['skill'] = wx.TextCtrl(current_panel,
                                       -1,
                                       '',
                                       style=wx.TE_READONLY | wx.TE_CENTER)
            tmp['lat'] = wx.TextCtrl(current_panel,
                                     -1,
                                     '',
                                     style=wx.TE_READONLY | wx.TE_CENTER)
            tmp['lon'] = wx.TextCtrl(current_panel,
                                     -1,
                                     '',
                                     style=wx.TE_READONLY | wx.TE_CENTER)

            current_box.Add(tmp['name'], 0, wx.EXPAND, 0)
            current_box.Add(tmp['id'], 0, wx.EXPAND, 0)
            current_box.Add(tmp['skill'], 0, wx.EXPAND, 0)
            current_box.Add(tmp['lat'], 0, wx.EXPAND, 0)
            current_box.Add(tmp['lon'], 0, wx.EXPAND, 0)

            self.current_ctrl.append(tmp)

        current_space = 139
        current_box.Add(wx.Size(current_space, 0), 0)
        current_box.Add(wx.Size(current_space, 0), 0)
        current_box.Add(wx.Size(current_space, 0), 0)
        current_box.Add(wx.Size(current_space, 0), 0)
        current_box.Add(wx.Size(current_space, 0), 0)

        current_panel.SetSizer(current_box)

        current_panel.Show(False)

        self.panels[current_action.GetId()] = current_panel

        #Main Sizer
        ##########################################################################
        self.main_box = wx.BoxSizer()

        self.main_box.Add(main_panel, 0, wx.EXPAND, 0)
        self.main_box.Add(spectrum_panel, 0, wx.EXPAND, 0)
        self.main_box.Add(manage_panel, 0, wx.EXPAND, 0)
        self.main_box.Add(graphic_panel, 0, wx.EXPAND, 0)
        self.main_box.Add(new_panel, 0, wx.EXPAND, 0)
        self.main_box.Add(current_panel, 0, wx.EXPAND, 0)

        self.SetSizer(self.main_box)

        self.Bind(wx.EVT_TIMER, self.timer_handler, id=self.timer.GetId())

        #Connection to Controller
        ##########################################################################
        self.__set_new_users = set_new_users
        self.__make_freq_request = make_freq_requests
        self.__release_freq = release_freq
        self.__set_emphasis = set_emphasis
        self.__get_freq_data = get_freq_data
        self.__get_user_data = get_user_data
        self.__get_geoloc_data = get_geoloc_data
Exemplo n.º 28
0
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self,
                           id=wxID_DLGTELESCOPESETUP,
                           name='',
                           parent=prnt,
                           pos=wx.Point(814, 390),
                           size=wx.Size(260, 111),
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=_('Telescope quirks setup'))
        self.SetClientSize(wx.Size(244, 73))

        self.btnOK = wx.Button(id=wxID_DLGTELESCOPESETUPBTNOK,
                               label=_('OK'),
                               name='btnOK',
                               parent=self,
                               pos=wx.Point(155, 42),
                               size=wx.Size(75, 23),
                               style=0)
        self.btnOK.Bind(wx.EVT_BUTTON,
                        self.OnBtnOKButton,
                        id=wxID_DLGTELESCOPESETUPBTNOK)

        self.lblSlewSettleTime = wx.StaticText(
            id=wxID_DLGTELESCOPESETUPLBLSLEWSETTLETIME,
            label=_('Slew settle extra wait'),
            name='lblSlewSettleTime',
            parent=self,
            pos=wx.Point(0, 0),
            size=wx.Size(155, 13),
            style=0)

        self.intSlewSettle = wx.lib.intctrl.IntCtrl(
            allow_long=False,
            allow_none=False,
            default_color=wx.BLACK,
            id=wxID_DLGTELESCOPESETUPINTSLEWSETTLE,
            limited=True,
            max=99,
            min=0,
            name='intSlewSettle',
            oob_color=wx.RED,
            parent=self,
            pos=wx.Point(155, 0),
            size=wx.Size(30, 21),
            style=0,
            value=0)
        self.intSlewSettle.SetMaxLength(2)
        self.intSlewSettle.SetInsertionPoint(0)

        self.slew_settle_unit = wx.StaticText(
            id=wxID_DLGTELESCOPESETUPSLEW_SETTLE_UNIT,
            label='s',
            name='slew_settle_unit',
            parent=self,
            pos=wx.Point(185, 0),
            size=wx.Size(6, 13),
            style=0)

        self.lblScopePollPeriod = wx.StaticText(
            id=wxID_DLGTELESCOPESETUPLBLSCOPEPOLLPERIOD,
            label=_('Telescope property caching'),
            name='lblScopePollPeriod',
            parent=self,
            pos=wx.Point(0, 21),
            size=wx.Size(155, 21),
            style=0)

        self.intPropertyAge = wx.lib.intctrl.IntCtrl(
            allow_long=False,
            allow_none=False,
            default_color=wx.BLACK,
            id=wxID_DLGTELESCOPESETUPINTPROPERTYAGE,
            limited=False,
            max=10,
            min=0,
            name='intPropertyAge',
            oob_color=wx.RED,
            parent=self,
            pos=wx.Point(155, 21),
            size=wx.Size(30, 21),
            style=0,
            value=0)

        self.staticText2 = wx.StaticText(id=wxID_DLGTELESCOPESETUPSTATICTEXT2,
                                         label='s',
                                         name='staticText2',
                                         parent=self,
                                         pos=wx.Point(185, 21),
                                         size=wx.Size(55, 13),
                                         style=0)

        self.btnCancel = wx.Button(id=wxID_DLGTELESCOPESETUPBTNCANCEL,
                                   label=_('Cancel'),
                                   name='btnCancel',
                                   parent=self,
                                   pos=wx.Point(0, 42),
                                   size=wx.Size(75, 23),
                                   style=0)
        self.btnCancel.Bind(wx.EVT_BUTTON,
                            self.OnBtnCancelButton,
                            id=wxID_DLGTELESCOPESETUPBTNCANCEL)

        self._init_sizers()
    def __init__(self, parent,config):
        # Settting the GUI size and panels design
        displays = (wx.Display(i) for i in range(wx.Display.GetCount())) # Gets the number of displays
        screenSizes = [display.GetGeometry().GetSize() for display in displays] # Gets the size of each display
        index = 0 # For display 1.
        screenWidth = screenSizes[index][0]
        screenHeight = screenSizes[index][1]
        self.gui_size = (screenWidth*0.7,screenHeight*0.85)

        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = 'DeepLabCut2.0 - Refinement ToolBox',
                            size = wx.Size(self.gui_size), pos = wx.DefaultPosition, style = wx.RESIZE_BORDER|wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetStatusText("")
        self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyPressed)

        self.SetSizeHints(wx.Size(self.gui_size)) #  This sets the minimum size of the GUI. It can scale now!
###################################################################################################################################################

        # Spliting the frame into top and bottom panels. Bottom panels contains the widgets. The top panel is for showing images and plotting!

        topSplitter = wx.SplitterWindow(self)
        vSplitter = wx.SplitterWindow(topSplitter)

        self.image_panel = ImagePanel(vSplitter, config,self.gui_size)
        self.choice_panel = ScrollPanel(vSplitter)
        # self.choice_panel.SetupScrolling(scroll_x=True, scroll_y=True, scrollToTop=False)
        # self.choice_panel.SetupScrolling(scroll_x=True, scrollToTop=False)
        vSplitter.SplitVertically(self.image_panel,self.choice_panel, sashPosition=self.gui_size[0]*0.8)
        vSplitter.SetSashGravity(1)
        self.widget_panel = WidgetPanel(topSplitter)
        topSplitter.SplitHorizontally(vSplitter, self.widget_panel,sashPosition=self.gui_size[1]*0.83)#0.9
        topSplitter.SetSashGravity(1)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(topSplitter, 1, wx.EXPAND)
        self.SetSizer(sizer)

###################################################################################################################################################
        # Add Buttons to the WidgetPanel and bind them to their respective functions.

        widgetsizer = wx.WrapSizer(orient=wx.HORIZONTAL)
        self.load = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Load labels")
        widgetsizer.Add(self.load , 1, wx.ALL, 15)
        self.load.Bind(wx.EVT_BUTTON, self.browseDir)

        self.prev = wx.Button(self.widget_panel, id=wx.ID_ANY, label="<<Previous")
        widgetsizer.Add(self.prev , 1, wx.ALL, 15)
        self.prev.Bind(wx.EVT_BUTTON, self.prevImage)
        self.prev.Enable(False)

        self.next = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Next>>")
        widgetsizer.Add(self.next , 1, wx.ALL, 15)
        self.next.Bind(wx.EVT_BUTTON, self.nextImage)
        self.next.Enable(False)

        self.help = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Help")
        widgetsizer.Add(self.help , 1, wx.ALL, 15)
        self.help.Bind(wx.EVT_BUTTON, self.helpButton)
        self.help.Enable(True)

        self.zoom = wx.ToggleButton(self.widget_panel, label="Zoom")
        widgetsizer.Add(self.zoom , 1, wx.ALL, 15)
        self.zoom.Bind(wx.EVT_TOGGLEBUTTON, self.zoomButton)
        self.widget_panel.SetSizer(widgetsizer)
        self.zoom.Enable(False)

        self.home = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Home")
        widgetsizer.Add(self.home , 1, wx.ALL,15)
        self.home.Bind(wx.EVT_BUTTON, self.homeButton)
        self.widget_panel.SetSizer(widgetsizer)
        self.home.Enable(False)

        self.pan = wx.ToggleButton(self.widget_panel, id=wx.ID_ANY, label="Pan")
        widgetsizer.Add(self.pan , 1, wx.ALL, 15)
        self.pan.Bind(wx.EVT_TOGGLEBUTTON, self.panButton)
        self.widget_panel.SetSizer(widgetsizer)
        self.pan.Enable(False)

        self.lock = wx.CheckBox(self.widget_panel, id=wx.ID_ANY, label="Lock View")
        widgetsizer.Add(self.lock, 1, wx.ALL, 15)
        self.lock.Bind(wx.EVT_CHECKBOX, self.lockChecked)
        self.widget_panel.SetSizer(widgetsizer)
        self.lock.Enable(False)

        self.save = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Save")
        widgetsizer.Add(self.save , 1, wx.ALL, 15)
        self.save.Bind(wx.EVT_BUTTON, self.saveDataSet)
        self.save.Enable(False)

        widgetsizer.AddStretchSpacer(15)
        self.quit = wx.Button(self.widget_panel, id=wx.ID_ANY, label="Quit")
        widgetsizer.Add(self.quit , 1, wx.ALL|wx.ALIGN_RIGHT, 15)
        self.quit.Bind(wx.EVT_BUTTON, self.quitButton)

        self.widget_panel.SetSizer(widgetsizer)
        self.widget_panel.SetSizerAndFit(widgetsizer)
        self.widget_panel.Layout()

###############################################################################################################################
        # Variable initialization
        self.currentDirectory = os.getcwd()
        self.index = []
        self.iter = []
        self.threshold = []
        self.file = 0
        self.updatedCoords = []
        self.drs = []
        self.cfg = auxiliaryfunctions.read_config(config)
        self.humanscorer = self.cfg['scorer']
        self.move2corner = self.cfg['move2corner']
        self.center = self.cfg['corner2move2']
        self.colormap = plt.get_cmap(self.cfg['colormap'])
        self.colormap = self.colormap.reversed()
        self.markerSize = self.cfg['dotsize']
        self.alpha = self.cfg['alphavalue']
        self.iterationindex = self.cfg['iteration']
        self.project_path=self.cfg['project_path']
        self.bodyparts = self.cfg['bodyparts']
        self.threshold = 0.1
        self.img_size = (10,6)# (imgW, imgH)  # width, height in inches.
        self.preview = False
        self.view_locked=False
        # Workaround for MAC - xlim and ylim changed events seem to be triggered too often so need to make sure that the
        # xlim and ylim have actually changed before turning zoom off
        self.prezoom_xlim=[]
        self.prezoom_ylim=[]
        from deeplabcut.utils import auxfun_multianimal
        self.individual_names,self.uniquebodyparts,self.multianimalbodyparts = auxfun_multianimal.extractindividualsandbodyparts(self.cfg)
        # self.choiceBox,self.visualization_rdb = self.choice_panel.addRadioButtons()
        self.Colorscheme = visualization.get_cmap(len(self.individual_names),self.cfg['colormap'])
    def __init__(self, parent):
        wx.Dialog.__init__(self,
                           parent,
                           id=wx.ID_ANY,
                           title=u"Desmantelado de Campaña",
                           pos=wx.DefaultPosition,
                           size=wx.Size(945, 510),
                           style=wx.DEFAULT_DIALOG_STYLE)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))

        gbSizer1 = wx.GridBagSizer(0, 0)
        gbSizer1.SetFlexibleDirection(wx.BOTH)
        gbSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.st_titulo = wx.StaticText(self, wx.ID_ANY,
                                       u"Listado de Desmantelado",
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        self.st_titulo.Wrap(-1)
        self.st_titulo.SetFont(wx.Font(11, 70, 90, 90, False, wx.EmptyString))

        gbSizer1.Add(self.st_titulo, wx.GBPosition(0, 0), wx.GBSpan(1, 1),
                     wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 20)

        self.btn_generar = wx.Button(self, wx.ID_ANY, u"Generar reporte",
                                     wx.DefaultPosition, wx.Size(120, 30), 0)
        self.btn_generar.SetFont(wx.Font(11, 70, 90, 90, False,
                                         wx.EmptyString))

        gbSizer1.Add(self.btn_generar, wx.GBPosition(1, 0), wx.GBSpan(1, 1),
                     wx.TOP | wx.LEFT, 20)

        sbSizer1 = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, wx.EmptyString), wx.VERTICAL)

        self.grilla = wx.grid.Grid(self, wx.ID_ANY, wx.DefaultPosition,
                                   wx.Size(870, 300), 0)

        # Grid
        self.grilla.CreateGrid(0, 9)
        self.grilla.EnableEditing(True)
        self.grilla.EnableGridLines(True)
        self.grilla.EnableDragGridSize(False)
        self.grilla.SetMargins(0, 0)

        # Columns
        self.grilla.SetColSize(0, 80)
        self.grilla.SetColSize(1, 50)
        self.grilla.SetColSize(2, 280)
        self.grilla.SetColSize(3, 80)
        self.grilla.SetColSize(4, 200)
        self.grilla.SetColSize(5, 80)
        self.grilla.SetColSize(6, 80)
        self.grilla.SetColSize(7, 170)
        self.grilla.SetColSize(8, 170)
        self.grilla.EnableDragColMove(False)
        self.grilla.EnableDragColSize(True)
        self.grilla.SetColLabelSize(30)
        self.grilla.SetColLabelValue(0, u"Código")
        self.grilla.SetColLabelValue(1, u"Cant.")
        self.grilla.SetColLabelValue(2, u"Apellido y nombre")
        self.grilla.SetColLabelValue(3, u"Sección")
        self.grilla.SetColLabelValue(4, u"Teléfono")
        self.grilla.SetColLabelValue(5, u"Camp")
        self.grilla.SetColLabelValue(6, u"Deuda")
        self.grilla.SetColLabelValue(7, u"Barrio")
        self.grilla.SetColLabelValue(8, u"Localidad")
        self.grilla.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Rows
        self.grilla.AutoSizeRows()
        self.grilla.EnableDragRowSize(True)
        self.grilla.SetRowLabelSize(50)
        self.grilla.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Label Appearance

        # Cell Defaults
        self.grilla.SetDefaultCellFont(
            wx.Font(11, 70, 90, 90, False, wx.EmptyString))
        self.grilla.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_TOP)
        sbSizer1.Add(self.grilla, 0, wx.ALL, 5)

        gbSizer1.Add(sbSizer1, wx.GBPosition(2, 0), wx.GBSpan(1, 1),
                     wx.EXPAND | wx.LEFT | wx.ALIGN_CENTER_HORIZONTAL, 20)

        self.btn_volver = wx.Button(self, wx.ID_CANCEL, u"Volver",
                                    wx.DefaultPosition, wx.Size(100, 30), 0)
        self.btn_volver.SetFont(wx.Font(11, 70, 90, 90, False, wx.EmptyString))

        gbSizer1.Add(self.btn_volver, wx.GBPosition(3, 0), wx.GBSpan(1, 1),
                     wx.ALIGN_RIGHT | wx.TOP | wx.BOTTOM | wx.LEFT, 20)

        self.SetSizer(gbSizer1)
        self.Layout()

        self.Centre(wx.BOTH)