예제 #1
0
 def display(self, parent):
     """\
     Actually builds the panel (with the text ctrl and the button to display
     the dialog) to set the value of the property interactively
     """
     self.id = wx.NewId()
     val = misc.wxstr(self.owner[self.name][0]())
     label = wxGenStaticText(parent, -1, _mangle(self.dispName),
                             size=(_label_initial_width, -1))
     label.SetToolTip(wx.ToolTip(_mangle(self.dispName)))
     if self.can_disable:
         self._enabler = wx.CheckBox(parent, self.id+1, '', size=(1, -1))
     self.text = wx.TextCtrl(parent, self.id, val, size=(1, -1))
     self.btn = wx.Button(parent, self.id+1, " ... ",
                         size=(_label_initial_width, -1))
     if self.can_disable:
         #self._enabler = wxCheckBox(parent, self.id+1, '', size=(1, -1))
         wx.EVT_CHECKBOX(self._enabler, self.id+1,
                      lambda event: self.toggle_active(event.IsChecked()))
         self.text.Enable(self.is_active())
         self.btn.Enable(self.is_active())
         self._enabler.SetValue(self.is_active())
         self._target = self.text
     wx.EVT_BUTTON(self.btn, self.id+1, self.display_dialog)
     sizer = wx.BoxSizer(wx.HORIZONTAL)
     sizer.Add(label, 2, wx.ALL|wx.ALIGN_CENTER, 3)
     if getattr(self, '_enabler', None) is not None:
         sizer.Add(self._enabler, 1, wx.ALL|wx.ALIGN_CENTER, 3)
         option = 3
     else:
         option = 4
     sizer.Add(self.text, option, wx.ALL|wx.ALIGN_CENTER, 3)
     sizer.Add(self.btn, 1, wx.ALL|wx.ALIGN_CENTER, 3)
     self.panel = sizer
     
     self.bind_event(self.on_change_val)
     wx.EVT_CHAR(self.text, self.on_char)
예제 #2
0
def setup_object_introspection(
    d3module,
    viewFrame,
    objectDict,
    renderWindow,
    objectChoice,
    introspect_button_id,
):
    """Setup all object introspection for standard module views with a
    choice for object introspection.  Call this if you have a
    wx.Choice and wx.Button ready!

    viewFrame is the actual window of the module view.
    objectDict is a dictionary with object name strings as keys and object
    instances as values.
    renderWindow is an optional renderWindow that'll be used for updating,
    pass as None if you don't have this.
    objectChoice is the object choice widget.
    objectChoiceId is the event id connected to the objectChoice widget.

    In order to use this, the module HAS to use the
    IntrospectModuleMixin.

    """

    # fill out the objectChoice with the object names
    objectChoice.Clear()
    for objectName in objectDict.keys():
        objectChoice.Append(objectName)
    # default on first object
    objectChoice.SetSelection(0)

    # setup the two default callbacks
    wx.EVT_BUTTON(
        viewFrame, introspect_button_id,
        lambda e: d3module._defaultObjectChoiceCallback(
            viewFrame, renderWindow, objectChoice, objectDict))
예제 #3
0
    def __init__(self, parent, quote):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)

        # pre-init
        self.m_id = wx.NewId()
        self.m_quote = quote
        self.m_parent = parent

        # post-init
        pre.Create(parent, -1, "%s %s - %s" % (message('quote_title'),self.m_quote.ticker(),self.m_quote.market()), size=(560,370))
        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        # property panel
        self.m_propwindow = iTradeQuotePropertiesPanel(self,wx.NewId(),self.m_quote,None)
        sizer.Add(self.m_propwindow, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        # CLOSE
        btn = wx.Button(self, wx.ID_CANCEL, message('close'))
        btn.SetHelpText(message('close_desc'))
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnClose)
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)
예제 #4
0
    def __init__(self, parent, wxId, id, style):
        # Create a wxButton of the appropriate type.
        if style != Button.STYLE_MINI:
            widget = wx.Button(parent, wxId, uniConv(language.translate(id)))
        else:
            widget = wx.ToggleButton(parent, wxId,
                                     uniConv(language.translate(id)))

        # Default buttons are usually a bit different visually.
        if style == Button.STYLE_DEFAULT:
            widget.SetDefault()

        base.Widget.__init__(self, widget)
        self.widgetId = id

        if style == Button.STYLE_MINI:
            # The mini buttons use the small style.
            self.setSmallStyle()
            # The size of the mini buttons is configurable.
            bestSize = widget.GetBestSize()
            width = 30
            height = bestSize[1]
            try:
                width = st.getSystemInteger('button-mini-width')
                if st.getSystemInteger('button-mini-height'):
                    height = st.getSystemInteger('button-mini-height')
            except:
                pass
            widget.SetMinSize((width, height))

        if style != Button.STYLE_MINI:
            # We will handle the click event ourselves.
            wx.EVT_BUTTON(parent, wxId, self.onClick)
            #self.updateDefaultSize()
        else:
            # Pop back up when toggled down.
            wx.EVT_TOGGLEBUTTON(parent, wxId, self.onToggle)
예제 #5
0
    def Packages(self, nom):
        self.panelPackages = wx.Panel(self, -1)
        self.txtPackages = wx.StaticText(self.panelPackages, -1, _(nom),
                                         (10, 10), wx.DefaultSize)
        self.txtPackages.SetFont(self.fontTitle)

        self.Menu = wx.ListBox(self.panelPackages,
                               99,
                               pos=(15, 45),
                               size=(430, 235),
                               style=Variables.widget_borders)
        self.PackageButton = wx.Button(self.panelPackages,
                                       98,
                                       _("Install"),
                                       pos=(10, 295))

        try:
            self.available_packages = open(
                Variables.playonlinux_rep +
                "/configurations/listes/POL_Functions", "r").read()
            self.available_packages = string.split(self.available_packages,
                                                   "/")
            self.available_packages_ = []
            for key in self.available_packages:
                if ("POL_Install" in key):
                    self.available_packages_.append(
                        key.replace("POL_Install_", ""))
            self.available_packages.sort()
            self.Menu.InsertItems(self.available_packages_, 0)
            self.Menu.Select(0)
        except:  # File does not exits ; it will be created when pol is updated
            pass
        #$REPERTOIRE/configurations/listes/
        wx.EVT_LISTBOX_DCLICK(self, 99, self.install_package)
        wx.EVT_BUTTON(self, 98, self.install_package)

        self.AddPage(self.panelPackages, nom)
예제 #6
0
    def General(self, nom):
        self.panelGeneral = wx.Panel(self, -1)
        self.AddPage(self.panelGeneral, nom)
        self.general_elements = {}
        # Les polices
        if(os.environ["POL_OS"] == "Mac"):
            self.fontTitle = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "", wx.FONTENCODING_DEFAULT)
            self.caption_font = wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,False, "", wx.FONTENCODING_DEFAULT)
        else :
            self.fontTitle = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "", wx.FONTENCODING_DEFAULT)
            self.caption_font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,False, "", wx.FONTENCODING_DEFAULT)

        self.txtGeneral = wx.StaticText(self.panelGeneral, -1, _("General"), (10,10), wx.DefaultSize)
        self.txtGeneral.SetFont(self.fontTitle)

        self.AddGeneralButton(_("Make a new shortcut from this virtual drive"),"newshort",1)
        self.AddGeneralChamp(_("Name"),"name","",2)
        self.AddGeneralElement(_("Wine version"),"wineversion",[],[],3)
        self.AddGeneralChamp(_("Debug flags"), "winedebug", "", 4)

        self.AddGeneralElement(_("Virtual drive"), "wineprefix", playonlinux.Get_Drives(), playonlinux.Get_Drives(), 5)

        self.AddGeneralChamp(_("Arguments"), "arguments", "", 6)

        self.configurator_title = wx.StaticText(self.panelGeneral, -1, "", (10,294), wx.DefaultSize)
        self.configurator_title.SetFont(self.fontTitle)
        self.configurator_button = wx.Button(self.panelGeneral, 106, _("Run configuration wizard"), pos=(15,324))


        wx.EVT_TEXT(self, 202, self.setname)
        wx.EVT_TEXT(self, 206, self.setargs)
        wx.EVT_TEXT(self, 204, self.setwinedebug)

        wx.EVT_COMBOBOX(self, 203, self.assign)
        wx.EVT_COMBOBOX(self, 205, self.assignPrefix)
        wx.EVT_BUTTON(self, 601, self.Parent.Parent.Parent.WineVersion)
예제 #7
0
    def __init__(self, parent, parameters):
        BaseDialog.__init__(self, parent, parameters.id(), parameters.label(),
                            (700, 300))
        self.thePersonaName = ''
        self.theVariable = ''
        self.theModalQualifier = ''
        self.theCharacteristic = ''
        self.theGrounds = []
        self.theWarrant = []
        self.theBacking = []
        self.theRebuttal = []
        self.isCreate = True

        self.theId = -1
        self.panel = 0
        self.inPersona = False
        if (parameters.__class__.__name__ ==
                'PersonaCharacteristicDialogParameters'):
            self.inPersona = True

        if (self.inPersona):
            self.thePersonaName = parameters.persona()
            self.theVariable = parameters.behaviouralVariable()

        self.commitVerb = 'Add'

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.panel = PersonaCharacteristicNotebook(self, self.thePersonaName)
        mainSizer.Add(self.panel, 1, wx.EXPAND)
        mainSizer.Add(
            self.buildCommitButtonSizer(PERSONACHARACTERISTIC_BUTTONCOMMIT_ID,
                                        True), 0, wx.CENTER)

        self.SetSizer(mainSizer)
        wx.EVT_BUTTON(self, PERSONACHARACTERISTIC_BUTTONCOMMIT_ID,
                      self.onCommit)
예제 #8
0
    def POL_SetupWindow_checkbox_list(self, message, title, liste, cut):
        self.Destroy_all()
        self.DrawDefault(message, title)

        self.scrolled_panel.Show()
        self.space = message.count("\\n") + 1

        self.scrolled_panel.SetPosition((20, 85 + self.space * 16))
        self.areaList = string.split(liste, cut)

        # We have to destroy all previous items (catching exception in case one is already destroyed)
        self.i = 0
        try:
            while (self.i <= len(self.item_check)):
                self.item_check[self.i].Destroy()
                self.i += 1
        except:
            pass
        self.item_check = []

        # Now we can rebuild safely the widget
        self.i = 0
        while (self.i < len(self.areaList)):
            self.item_check.append(
                wx.CheckBox(self.scrolled_panel,
                            -1,
                            pos=(0, (self.i * 25)),
                            label=str(self.areaList[self.i])))
            self.i += 1

        self.scrolled_panel.SetVirtualSize((0, self.i * (25)))
        self.scrolled_panel.SetScrollRate(0, 25)
        self.DrawCancel()
        self.DrawNext()
        self.separator = cut
        wx.EVT_BUTTON(self, wx.ID_FORWARD, self.release_checkboxes)
예제 #9
0
    def __init__(self, parent, objt, rType):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           'Edit Use Case Contribution',
                           style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX,
                           size=(475, 300))
        self.theSource = objt.source()
        self.theDestination = objt.destination()
        self.theMeansEnd = objt.meansEnd()
        self.theContribution = objt.contribution()
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.panel = UseCaseContributionPanel(self)
        mainSizer.Add(self.panel, 1, wx.EXPAND)
        self.SetSizer(mainSizer)
        wx.EVT_BUTTON(self, REFERENCECONTRIBUTION_BUTTONCOMMIT_ID,
                      self.onCommit)

        if (objt.meansEnd() != ''):
            self.theCommitVerb = 'Create'
            self.SetLabel = 'Create Reference Contribution'
        else:
            self.theCommitVerb = 'Edit'
        self.panel.load(objt, rType)
예제 #10
0
    def __init__(self, parent, id, cert, certMgr):

        wx.Dialog.__init__(self,
                           None,
                           id,
                           "",
                           size=wx.Size(700, 400),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        title = GetCNFromX509Subject(cert.GetSubject())
        self.SetTitle(title)

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.panel = CertificateViewerPanel(self, -1, cert, certMgr)
        sizer.Add(self.panel, 1, wx.EXPAND)

        b = wx.Button(self, -1, "Close")
        sizer.Add(b, 0)
        wx.EVT_BUTTON(self, b.GetId(), self.OnClose)
        wx.EVT_CLOSE(self, self.OnClose)

        self.SetSizer(sizer)
        self.SetAutoLayout(1)
예제 #11
0
    def Populate(self, title, icon=None):
        self.title = title
        self.icon = icon

        panel = wx.Panel(self, wx.ID_ANY)

        vsz = wx.BoxSizer(wx.VERTICAL)
        hsz = wx.BoxSizer(wx.HORIZONTAL)

        if self.icon is not None:
            hsz.Add(wx.StaticBitmap(panel, wx.ID_ANY, self.icon), 0,
                    wx.ALL|wx.ALIGN_CENTRE, 2)

        font = wx.NORMAL_FONT
        font.SetPointSize(8)
        font.SetWeight(wx.FONTWEIGHT_BOLD)

        titleCtrl = wx.StaticText(panel, wx.ID_ANY, self.title)
        titleCtrl.SetFont(font)
        hsz.Add(titleCtrl, 1, wx.ALL|wx.ALIGN_CENTRE, 2)

        btn = self.CloseButton(panel)
        if btn is not None:
            hsz.Add(btn, 0, wx.ALL, 2)
            wx.EVT_BUTTON(btn, wx.ID_ANY, self.DoClose)

        vsz.Add(hsz, 0, wx.ALL|wx.EXPAND, 2)

        self.AddInnerContent(vsz, panel)

        panel.SetSizer(vsz)

        sz = wx.BoxSizer()
        sz.Add(panel, 1, wx.EXPAND)
        self.SetSizer(sz)
        self.Fit()
예제 #12
0
    def GetMyControls(self):
        vs=wx.BoxSizer(wx.VERTICAL)
        _sbs=wx.StaticBoxSizer(wx.StaticBox(self, -1, 'User Selection'),
                               wx.VERTICAL)
        _fgs=wx.FlexGridSizer(0, 2, 5, 5)
        _fgs.Add(wx.StaticText(self, -1, 'Phone Model:'),
                 0, wx.EXPAND|wx.ALL, 0)
        self._model=wx.StaticText(self, -1, '')
        _fgs.Add(self._model, 0, wx.EXPAND|wx.ALL, 0)
        _fgs.Add(wx.StaticText(self, -1, 'Port:'),
                 0, wx.EXPAND|wx.ALL, 0)
        self._port=wx.StaticText(self, -1, '')
        _fgs.Add(self._port, 0, wx.EXPAND|wx.ALL, 0)
        _fgs.Add(wx.StaticText(self, -1, 'Detection Status:'),
                 0, wx.EXPAND|wx.ALL, 0)
        self._status=wx.StaticText(self, -1, '')
        _fgs.Add(self._status, 0, wx.EXPAND|wx.ALL, 0)

        _sbs.Add(_fgs, 1, wx.EXPAND, 0)
        vs.Add(_sbs, 0, wx.EXPAND|wx.ALL, 5)
        self._det_btn=wx.Button(self, -1, 'Detect Phone')
        vs.Add(self._det_btn, 0, wx.ALL, 5)
        wx.EVT_BUTTON(self, self._det_btn.GetId(), self.OnDetect)
        return vs
예제 #13
0
    def __init__(self, parent):
        super(SyncMLWarningDialog, self).__init__(parent, wx.ID_ANY, _('Compatibility warning'))

        textWidget = wx.StaticText(self, wx.ID_ANY,
                                   _('The SyncML feature is disabled, because the module\n'
                                     'could not be loaded. This may be because your platform\n'
                                     'is not supported, or under Windows, you may be missing\n'
                                     'some mandatory DLLs. Please see the SyncML section of\n'
                                     'the online help for details (under "Troubleshooting").'))
        self.checkbox = wx.CheckBox(self, wx.ID_ANY, _('Never show this dialog again'))
        self.checkbox.SetValue(True)
        button = wx.Button(self, wx.ID_ANY, _('OK'))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(textWidget, 0, wx.ALL, 10)
        sizer.Add(self.checkbox, 0, wx.ALL, 3)
        sizer.Add(button, 0, wx.ALL|wx.ALIGN_CENTRE, 3)

        self.SetSizer(sizer)

        wx.EVT_BUTTON(button, wx.ID_ANY, self.OnOK)
        wx.EVT_CLOSE(self, self.OnOK)

        self.Fit()
예제 #14
0
    def _bindEvents(self):
        controlFrame = self.slice3dVWR.controlFrame

        wx.EVT_BUTTON(controlFrame, controlFrame.createSliceButtonId,
                      self._handlerCreateSlice)

        # for ortho view use sliceDirection.createOrthoView()

        wx.grid.EVT_GRID_CELL_RIGHT_CLICK(self._grid,
                                          self._handlerGridRightClick)
        wx.grid.EVT_GRID_LABEL_RIGHT_CLICK(self._grid,
                                           self._handlerGridRightClick)

        wx.grid.EVT_GRID_RANGE_SELECT(self._grid, self._handlerGridRangeSelect)

        # now do the fusion stuff
        wx.EVT_CHOICE(self.slice3dVWR.controlFrame,
                      self.slice3dVWR.controlFrame.overlayModeChoice.GetId(),
                      self._handlerOverlayModeChoice)

        wx.EVT_COMMAND_SCROLL(
            self.slice3dVWR.controlFrame,
            self.slice3dVWR.controlFrame.fusionAlphaSlider.GetId(),
            self._handlerFusionAlphaSlider)
예제 #15
0
 def __init__(self, parent, reqList, setTargets, envName):
     wx.Dialog.__init__(self,
                        parent,
                        PROPERTY_ID,
                        'Add Target',
                        style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX
                        | wx.THICK_FRAME | wx.RESIZE_BORDER,
                        size=(400, 250))
     b = Borg()
     self.dbProxy = b.dbProxy
     self.theTarget = ''
     self.theEffectiveness = ''
     self.theRationale = ''
     self.commitLabel = 'Add'
     mainSizer = wx.BoxSizer(wx.VERTICAL)
     self.theTargetDictionary = self.dbProxy.targetNames(reqList, envName)
     defaultTargets = set(self.theTargetDictionary.keys())
     targetList = list(defaultTargets.difference(setTargets))
     mainSizer.Add(
         WidgetFactory.buildComboSizerList(self, 'Target', (87, 30),
                                           TARGET_COMBOTARGET_ID,
                                           targetList), 0, wx.EXPAND)
     mainSizer.Add(
         WidgetFactory.buildComboSizerList(
             self, 'Effectiveness', (87, 30), TARGET_COMBOEFFECTIVENESS_ID,
             ['None', 'Low', 'Medium', 'High']), 0, wx.EXPAND)
     mainSizer.Add(
         WidgetFactory.buildMLTextSizer(self, 'Rationale', (87, 60),
                                        TARGET_TEXTRATIONALE_ID), 1,
         wx.EXPAND)
     mainSizer.Add(
         WidgetFactory.buildAddCancelButtonSizer(self,
                                                 TARGET_BUTTONCOMMIT_ID), 0,
         wx.ALIGN_CENTER)
     self.SetSizer(mainSizer)
     wx.EVT_BUTTON(self, TARGET_BUTTONCOMMIT_ID, self.onCommit)
예제 #16
0
    def add_button(self,
                   action,
                   sizer,
                   method=None,
                   enabled=True,
                   name=None,
                   default=False):
        """ Creates a button.
        """
        ui = self.ui
        if ((action.defined_when != '')
                and (not ui.eval_when(action.defined_when))):
            return None

        if name is None:
            name = action.name
        id = action.id
        button = wx.Button(self.control, -1, name)
        button.Enable(enabled)
        if default:
            button.SetDefault()
        if (method is None) or (action.enabled_when != '') or (id != ''):
            editor = ButtonEditor(ui=ui, action=action, control=button)
            if id != '':
                ui.info.bind(id, editor)
            if action.visible_when != '':
                ui.add_visible(action.visible_when, editor)
            if action.enabled_when != '':
                ui.add_enabled(action.enabled_when, editor)
            if method is None:
                method = editor.perform
        wx.EVT_BUTTON(self.control, button.GetId(), method)
        sizer.Add(button, 0, wx.LEFT, 5)
        if action.tooltip != '':
            button.SetToolTipString(action.tooltip)
        return button
예제 #17
0
    def __init__(self, parent, title, message):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.RESIZE_BOX,
                           size=(400, 300),
                           title=title)

        fd, self.filename = tempfile.mkstemp('.html')
        os.write(fd, message)
        os.close(fd)

        box = wx.BoxSizer(wx.VERTICAL)
        if wx.Platform == '__WXMSW__':
            self.html = IEHtmlWindow(self)
        else:
            self.html = DefaultHtmlWindow(self)
        self.html.Load(self.filename)
        if wx.Platform == '__WXMSW__':
            box.Add(self.html.ie, 1, wx.EXPAND | wx.ALL, 1)
        else:
            box.Add(self.html, 1, wx.EXPAND | wx.ALL, 1)
        box2 = wx.BoxSizer(wx.HORIZONTAL)
        btnOK = wx.Button(self, wx.ID_OK, tr("OK"))
        btnOK.SetDefault()
        box2.Add(btnOK, 0, 0)
        box.Add(box2, 0, wx.ALIGN_CENTER | wx.ALL, 2)

        self.SetSizer(box)
        #               self.SetAutoLayout(True)

        #               box.Fit(self)

        wx.EVT_BUTTON(btnOK, wx.ID_OK, self.OnOk)
        wx.EVT_CLOSE(self, self.OnOk)
예제 #18
0
    def setup(self, parent):
        super(BackgroundCalcCtrl, self).setup(parent)
        
        #AvoPlotXYSubplot is a class, not an object/instance so you can't do this!
        #also get_mpl_axes is a method - so you would need () to make this do what you intended
        #self.axes = AvoPlotXYSubplot.get_mpl_axes
        self.axes = self.series.get_parent_element().get_mpl_axes()
        
        self.plot_obj = parent
        spec_type = classify_spectrum
        
        h2o_button = wx.Button(self, wx.ID_ANY, "Fit H2O")
        self.peak_height_text = wx.StaticText(self, -1, "Peak Height:\n")
        self.Add(self.peak_height_text)
        self.Add(h2o_button, 0, wx.ALIGN_TOP|wx.ALL,border=10)
#        sizer = wx.StaticText(self, -1, "Spec Type:\n%s"%spec_type, 0, wx.ALIGN_TOP|wx.ALL)
#        sizer_peak_height = wx.sizer(self.peak_height_text,0,wx.ALIGN_TOP|wx.ALL)
#        self.Add(sizer)
#        self.Add(sizer_peak_height)
        wx.EVT_BUTTON(self, h2o_button.GetId(), self.fit_h2o)
        
#        self.SetSizer(sizer)
#        self.sizer.Fit(self)
        self.SetAutoLayout(True)
예제 #19
0
파일: SeqGui.py 프로젝트: wl2wl2/biopython
    def __init__(self, parent, log):
        self.parent = parent
        wx.Panel.__init__(self, parent, -1)
        apply_button = wx.Button(self, ID_APPLY, "Apply")
        clear_button = wx.Button(self, ID_CLEAR, "Clear")
        close_button = wx.Button(self, ID_CLOSE, "Close")
        wx.EVT_BUTTON(self, ID_CLOSE, self.OnClose)
        wx.EVT_BUTTON(self, ID_APPLY, self.OnApply)
        wx.EVT_BUTTON(self, ID_CLEAR, self.OnClear)

        lc = wx.LayoutConstraints()
        lc.bottom.SameAs(self, wx.Bottom, 10)
        lc.left.SameAs(self, wx.Left, 10)
        lc.height.AsIs()
        lc.width.PercentOf(self, wx.Width, 25)
        apply_button.SetConstraints(lc)

        lc = wx.LayoutConstraints()
        lc.bottom.SameAs(self, wx.Bottom, 10)
        lc.left.RightOf(apply_button, 5)
        lc.height.AsIs()
        lc.width.PercentOf(self, wx.Width, 25)
        clear_button.SetConstraints(lc)

        lc = wx.LayoutConstraints()
        lc.bottom.SameAs(self, wx.Bottom, 10)
        lc.left.RightOf(clear_button, 5)
        lc.height.AsIs()
        lc.width.PercentOf(self, wx.Width, 25)
        close_button.SetConstraints(lc)

        src_static = wx.StaticText(self,
                                   -1,
                                   'Original Sequence',
                                   style=wx.ALIGN_CENTER)
        lc = wx.LayoutConstraints()
        lc.top.SameAs(self, wx.Top, 5)
        lc.left.SameAs(self, wx.Left, 5)
        lc.height.AsIs()
        lc.right.SameAs(self, wx.Right, 5)
        src_static.SetConstraints(lc)

        src_text = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        lc = wx.LayoutConstraints()
        lc.top.Below(src_static, 5)
        lc.left.SameAs(self, wx.Left, 5)
        lc.height.PercentOf(self, wx.Height, 30)
        lc.right.SameAs(self, wx.Right, 5)
        src_text.SetConstraints(lc)
        self.src_text = src_text

        dest_static = wx.StaticText(self,
                                    -1,
                                    'Transformed Sequence',
                                    style=wx.ALIGN_CENTER)
        lc = wx.LayoutConstraints()
        lc.top.Below(src_text, 5)
        lc.left.SameAs(self, wx.Left, 5)
        lc.height.AsIs()
        lc.right.SameAs(self, wx.Right, 5)
        dest_static.SetConstraints(lc)

        dest_text = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        lc = wx.LayoutConstraints()
        lc.top.Below(dest_static, 5)
        lc.left.SameAs(self, wx.Left, 5)
        lc.height.PercentOf(self, wx.Height, 30)
        lc.right.SameAs(self, wx.Right, 5)
        dest_text.SetConstraints(lc)
        self.dest_text = dest_text
예제 #20
0
    def __init__(self, PanelData, MainFrame):

        # Create Data Frame window
        wx.Panel.__init__(self, parent=PanelData, style=wx.SUNKEN_BORDER)

        # Specify relevant variables
        self.MainFrame = MainFrame
        self.MainFrame.saved = False
        self.MainFrame.Dataset = {}

        # Panel: Data Handler
        self.PanelDataHandler = wx.Panel(self, wx.ID_ANY)
        sizerPanelDataHandler = wx.BoxSizer(wx.VERTICAL)

        # Text: Create, Modify or Save Dataset
        TxtDataset = wx.StaticText(self.PanelDataHandler,
                                   wx.ID_ANY,
                                   style=wx.CENTRE,
                                   label="Create or Modify Dataset")
        sizerPanelDataHandler.Add(TxtDataset, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(3)

        # Panel: Create, Modify or Save Dataset
        PanelDataset = wx.Panel(self.PanelDataHandler, wx.ID_ANY)
        sizerPanelDataset = wx.BoxSizer(wx.HORIZONTAL)
        self.MainFrame.ButtonDataCreate = wx.Button(
            PanelDataset,
            wx.ID_ANY,
            size=(175, 28),
            style=wx.CENTRE,
            label="&Create new Dataset")
        sizerPanelDataset.Add(self.MainFrame.ButtonDataCreate, 0, wx.EXPAND)
        sizerPanelDataset.AddSpacer(5)
        self.MainFrame.ButtonDataModify = wx.Button(
            PanelDataset,
            wx.ID_ANY,
            size=(175, 28),
            style=wx.CENTRE,
            label="&Modify loaded Dataset")
        self.MainFrame.ButtonDataModify.Disable()
        sizerPanelDataset.Add(self.MainFrame.ButtonDataModify, 0, wx.EXPAND)
        PanelDataset.SetSizer(sizerPanelDataset)
        sizerPanelDataHandler.Add(PanelDataset, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(15)

        # Text: Save Dataset
        TxtSave = wx.StaticText(self.PanelDataHandler,
                                wx.ID_ANY,
                                style=wx.CENTRE,
                                label="Save Dataset")
        sizerPanelDataHandler.Add(TxtSave, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(3)

        # Panel: Save Dataset
        PanelSaveFile = wx.Panel(self.PanelDataHandler, wx.ID_ANY)
        sizerPanelSaveFile = wx.BoxSizer(wx.HORIZONTAL)
        self.DataSaveFile = wx.TextCtrl(PanelSaveFile,
                                        wx.ID_ANY,
                                        size=(500, 21),
                                        value=os.path.join(
                                            os.getcwd(), 'dataset.h5'))
        sizerPanelSaveFile.Add(self.DataSaveFile, 0, wx.EXPAND)
        self.MainFrame.ButtonDataSave = wx.Button(PanelSaveFile,
                                                  wx.ID_ANY,
                                                  label="&Save Dataset",
                                                  size=(110, 28))
        self.MainFrame.ButtonDataSave.Disable()
        sizerPanelSaveFile.Add(self.MainFrame.ButtonDataSave, 0, wx.EXPAND)
        PanelSaveFile.SetSizer(sizerPanelSaveFile)
        sizerPanelDataHandler.Add(PanelSaveFile, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(15)

        # Text: Load Dataset
        TxtLoad = wx.StaticText(self.PanelDataHandler,
                                wx.ID_ANY,
                                style=wx.CENTRE,
                                label="Load existing Dataset")
        sizerPanelDataHandler.Add(TxtLoad, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(3)

        # Panel: Load Dataset
        PanelLoadFile = wx.Panel(self.PanelDataHandler, wx.ID_ANY)
        sizerPanelLoadFile = wx.BoxSizer(wx.HORIZONTAL)
        self.DataLoadFile = wx.TextCtrl(PanelLoadFile,
                                        wx.ID_ANY,
                                        size=(500, 21),
                                        value=os.path.join(
                                            os.getcwd(), 'dataset.h5'))
        sizerPanelLoadFile.Add(self.DataLoadFile, 0, wx.EXPAND)
        self.MainFrame.ButtonDataLoad = wx.Button(PanelLoadFile,
                                                  wx.ID_ANY,
                                                  label="&Load Dataset",
                                                  size=(110, 28))
        sizerPanelLoadFile.Add(self.MainFrame.ButtonDataLoad, 0, wx.EXPAND)
        PanelLoadFile.SetSizer(sizerPanelLoadFile)
        sizerPanelDataHandler.Add(PanelLoadFile, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(15)

        # Text: Select Result Folder
        TxtSelect = wx.StaticText(self.PanelDataHandler,
                                  wx.ID_ANY,
                                  style=wx.CENTRE,
                                  label="Select Result Folder")
        sizerPanelDataHandler.Add(TxtSelect, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(3)

        # Panel: Select Result Folder
        PanelResult = wx.Panel(self.PanelDataHandler, wx.ID_ANY)
        sizerPanelResult = wx.BoxSizer(wx.HORIZONTAL)
        self.TextResult = wx.TextCtrl(PanelResult,
                                      wx.ID_ANY,
                                      size=(500, 21),
                                      value=os.path.join(os.getcwd(), 'STEN'))
        sizerPanelResult.Add(self.TextResult, 0, wx.EXPAND)
        self.MainFrame.ButtonResult = wx.Button(PanelResult,
                                                wx.ID_ANY,
                                                label="&Result Folder",
                                                size=(110, 28))
        sizerPanelResult.Add(self.MainFrame.ButtonResult, 0, wx.EXPAND)
        PanelResult.SetSizer(sizerPanelResult)
        sizerPanelDataHandler.Add(PanelResult, 0, wx.EXPAND)
        sizerPanelDataHandler.AddSpacer(40)

        # Panel: Model Information Panel
        PanelModelInfo = wx.Panel(self.PanelDataHandler, wx.ID_ANY)
        sizerModelInfo = wx.BoxSizer(wx.HORIZONTAL)
        self.TxtModelInfo = wx.StaticText(PanelModelInfo,
                                          wx.ID_ANY,
                                          label='',
                                          style=wx.ALIGN_LEFT,
                                          size=(100, 200))
        sizerModelInfo.Add(self.TxtModelInfo, 0, wx.EXPAND)
        PanelModelInfo.SetSizer(sizerModelInfo)
        sizerPanelDataHandler.Add(PanelModelInfo, 0, wx.EXPAND)

        # Panel: Calculation Progression
        PanelCalculation = wx.Panel(self.PanelDataHandler, wx.ID_ANY)
        sizerCalculation = wx.BoxSizer(wx.HORIZONTAL)
        self.TxtProgress = wx.StaticText(PanelCalculation,
                                         wx.ID_ANY,
                                         label='',
                                         style=wx.ALIGN_LEFT,
                                         size=(150, 200))
        sizerCalculation.Add(self.TxtProgress, 0, wx.EXPAND)
        PanelCalculation.SetSizer(sizerCalculation)
        sizerPanelDataHandler.Add(PanelCalculation, 0, wx.EXPAND)

        # Create vertical structure of Data Handler Frame
        sizerFrame = wx.BoxSizer(wx.VERTICAL)
        sizerFrame.AddSpacer(3)
        sizerFrame.Add(self.PanelDataHandler, 0, wx.EXPAND)
        self.SetSizer(sizerFrame)
        self.PanelDataHandler.SetSizer(sizerPanelDataHandler)

        # Button Events
        wx.EVT_BUTTON(self, self.MainFrame.ButtonDataCreate.Id,
                      self.createData)
        wx.EVT_BUTTON(self, self.MainFrame.ButtonDataModify.Id,
                      self.modifyData)
        wx.EVT_BUTTON(self, self.MainFrame.ButtonDataSave.Id, self.saveData)
        wx.EVT_BUTTON(self, self.MainFrame.ButtonDataLoad.Id, self.loadData)
        wx.EVT_BUTTON(self, self.MainFrame.ButtonResult.Id, self.resultFolder)
예제 #21
0
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title)
        if platform=='darwin':	# Default is too big on Mac
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        self.canvas=parent.canvas

        panel1 = wx.Panel(self,-1)
        grid1 = wx.FlexGridSizer(0, 4, 6, 6)
        grid1.AddGrowableCol(3, proportion=1)

        self.object = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.OBJ: self.object.SetValue(True)
        grid1.Add(self.object)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/obj.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add([0,0])
        grid1.Add(wx.StaticText(panel1, -1, '3D objects'))
        
        self.polygon= wx.CheckBox(panel1, -1, style=wx.CHK_3STATE)
        if self.canvas.locked&Locked.POLYGON==Locked.POLYGON:
            self.polygon.SetValue(True)
        elif self.canvas.locked&Locked.POLYGON:
            self.polygon.Set3StateValue(wx.CHK_UNDETERMINED)
        grid1.Add(self.polygon)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/unknown.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add([0,0])
        grid1.Add(wx.StaticText(panel1, -1, 'Polygons'))

        self.facade = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.FAC: self.facade.SetValue(True)
        grid1.Add([0,0])
        grid1.Add(self.facade)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/fac.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add(wx.StaticText(panel1, -1, 'Facades'))

        self.forest = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.FOR: self.forest.SetValue(True)
        grid1.Add([0,0])
        grid1.Add(self.forest)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/for.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add(wx.StaticText(panel1, -1, 'Forests'))

        self.draped = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.POL: self.draped.SetValue(True)
        grid1.Add([0,0])
        grid1.Add(self.draped)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/pol.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add(wx.StaticText(panel1, -1, 'Draped'))

        self.ortho  = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.ORTHO: self.ortho.SetValue(True)
        grid1.Add([0,0])
        grid1.Add(self.ortho)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/ortho.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add(wx.StaticText(panel1, -1, 'Orthophotos'))

        self.unknown = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.UNKNOWN: self.unknown.SetValue(True)
        grid1.Add([0,0])
        grid1.Add(self.unknown)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/unknown.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add(wx.StaticText(panel1, -1, 'Other'))

        self.network = wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.NET: self.network.SetValue(True)
        grid1.Add(self.network)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/net.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add([0,0])
        grid1.Add(wx.StaticText(panel1, -1, 'Networks'))

        self.exclusion= wx.CheckBox(panel1, -1)
        if self.canvas.locked&Locked.EXCLUSION: self.exclusion.SetValue(True)
        grid1.Add(self.exclusion)
        grid1.Add(wx.StaticBitmap(panel1, -1, wx.Bitmap("Resources/exc.png", wx.BITMAP_TYPE_PNG)))
        grid1.Add([0,0])
        grid1.Add(wx.StaticText(panel1, -1, 'Exclusions'))

        panel1.SetSizer(grid1)
        box2=myCreateStdDialogButtonSizer(self, wx.OK|wx.CANCEL)
        box0 = wx.BoxSizer(wx.VERTICAL)
        box0.Add(panel1, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 10)
        box0.Add(box2, 0, wx.ALL|wx.EXPAND, 10)
        self.SetSizerAndFit(box0)

        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)
        wx.EVT_CHECKBOX(self, self.polygon.GetId(), self.OnPolygons)
        wx.EVT_CHECKBOX(self, self.facade.GetId(), self.OnPolygon)
        wx.EVT_CHECKBOX(self, self.forest.GetId(), self.OnPolygon)
        wx.EVT_CHECKBOX(self, self.draped.GetId(), self.OnPolygon)
        wx.EVT_CHECKBOX(self, self.ortho.GetId(), self.OnPolygon)
        wx.EVT_CHECKBOX(self, self.unknown.GetId(), self.OnPolygon)
예제 #22
0
    def __init__(self, mw, parent, id=-1):
        wx.Panel.__init__(self, parent, id)
        self.mw=mw
        vbs=wx.BoxSizer(wx.VERTICAL)

        # General
        bs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "General"), wx.HORIZONTAL)
        bs.Add(wx.StaticText(self, -1, "Fingerprint"), 0, wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        self.fingerprint=wx.TextCtrl(self, -1, "a", style=wx.TE_READONLY,  size=(300,-1))
        bs.Add(self.fingerprint, 0, wx.EXPAND|wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        bs.Add(wx.StaticText(self, -1, ""), 0, wx.ALL, 5) # spacer
        bs.Add(wx.StaticText(self, -1, "Port"), 0, wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        self.porttext=wx.StaticText(self, -1, "<No Port>")
        bs.Add(self.porttext, 0, wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        vbs.Add(bs, 0, wx.EXPAND|wx.ALL, 5)

        # authorization
        bs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "Authorization"), wx.VERTICAL)
        hbs=wx.BoxSizer(wx.HORIZONTAL)
        butadd=wx.Button(self, wx.NewId(), "Add ...")
        hbs.Add(butadd, 0, wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        hbs.Add(wx.StaticText(self, -1, ""), 0, wx.ALL, 5) # spacer
        self.butedit=wx.Button(self, wx.NewId(), "Edit ...")
        self.butedit.Enable(False)
        hbs.Add(self.butedit, 0, wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        hbs.Add(wx.StaticText(self, -1, ""), 0, wx.ALL, 5) # spacer
        self.butdelete=wx.Button(self, wx.NewId(), "Delete")
        self.butdelete.Enable(False)
        hbs.Add(self.butdelete, 0, wx.ALL|wx.ALIGN_CENTRE_VERTICAL, 5)
        bs.Add(hbs, 0, wx.EXPAND|wx.ALL, 5)

        wx.EVT_BUTTON(self, butadd.GetId(), self.OnAddAuth)
        wx.EVT_BUTTON(self, self.butedit.GetId(), self.OnEditAuth)
        wx.EVT_BUTTON(self, self.butdelete.GetId(), self.OnDeleteAuth)

        # and the authorization listview
        self.authlist=wx.ListCtrl(self, wx.NewId(), style=wx.LC_REPORT|wx.LC_SINGLE_SEL)
        self.authlist.InsertColumn(0, "User")
        self.authlist.InsertColumn(1, "Allowed Addresses")
        self.authlist.InsertColumn(2, "Expires")
        self.authlist.SetColumnWidth(0, 300)
        self.authlist.SetColumnWidth(1, 300)
        self.authlist.SetColumnWidth(2, 100)
        bs.Add(self.authlist, 1, wx.EXPAND|wx.ALL, 5)
        
        vbs.Add(bs, 1, wx.EXPAND|wx.ALL, 5)
        self.itemDataMap={}
        wx.lib.mixins.listctrl.ColumnSorterMixin.__init__(self,3)

        wx.EVT_LIST_ITEM_ACTIVATED(self.authlist, self.authlist.GetId(), self.OnEditAuth)
        wx.EVT_LIST_ITEM_SELECTED(self.authlist, self.authlist.GetId(), self.OnAuthListItemFondled)
        wx.EVT_LIST_ITEM_DESELECTED(self.authlist, self.authlist.GetId(), self.OnAuthListItemFondled)
        wx.EVT_LIST_ITEM_FOCUSED(self.authlist, self.authlist.GetId(), self.OnAuthListItemFondled)

        # devices
        bs=wx.StaticBoxSizer(wx.StaticBox(self, -1, "Devices"), wx.VERTICAL)
        buttoggle=wx.Button(self, wx.NewId(), "Toggle Allowed")
        bs.Add(buttoggle, 0, wx.ALL, 5)
        self.devicelist=wx.ListCtrl(self, wx.NewId(), style=wx.LC_REPORT|wx.LC_SINGLE_SEL)
        self.devicelist.InsertColumn(0, "Allowed")
        self.devicelist.InsertColumn(1, "Name")
        self.devicelist.InsertColumn(2, "Available")
        self.devicelist.InsertColumn(3, "Description")
        self.devicelist.SetColumnWidth(0, 100)
        self.devicelist.SetColumnWidth(1, 300)
        self.devicelist.SetColumnWidth(2, 100)
        self.devicelist.SetColumnWidth(3, 300)
        bs.Add(self.devicelist, 1, wx.EXPAND|wx.ALL, 5)

        vbs.Add(bs, 1, wx.EXPAND|wx.ALL, 5)
        
        self.setupauthorization()
        self.SortListItems()
        
        self.SetSizer(vbs)
        self.SetAutoLayout(True)
예제 #23
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, (800, 600))

        hbox= wx.BoxSizer(wx.HORIZONTAL)
        vbox = wx.BoxSizer(wx.VERTICAL)
        hboxcontrols = wx.BoxSizer(wx.HORIZONTAL)
        hboxlist = wx.BoxSizer(wx.HORIZONTAL)

        vbox.Add(hboxcontrols, 1, wx.EXPAND)
        vbox.Add(hboxlist, 1, wx.EXPAND)

        #comment load motor and load led when working on gui
        #load motor
        motorSettings = settings.MotorSettings().get()
        self.motorController = motorControl.MotorControl(motorSettings)
        self.motorController.setAllSpeed(100)
        #parse motor setting to get min and max angle, store result in hash motors
        motors = {}
        motorsConfig=motorSettings["motorConfig"]
        for motor in motorsConfig:
            motors[motor[3]] = [motor[1], motor[2]]

        #load led
        self.ledController = python2arduino.Arduino()

        #uncomment when working on gui
        #motors = {"bowl": [0, 150], "bottom": [0, 150], "mid": [0, 150], "top": [0, 150], "head": [0, 150]}

        #visual element
  
        #bowl button
        pnlBowl = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlBowl, 1, wx.ALL |wx.EXPAND, 1)
        self.sldBowl = wx.Slider(pnlBowl, -1, motors["bowl"][0], motors["bowl"][0], motors["bowl"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textBowl = wx.StaticText(pnlBowl, -1, 'Bowl')
        vboxBowl = wx.BoxSizer(wx.VERTICAL)
        vboxBowl.Add(self.sldBowl, 1, wx.CENTER, 0)
        vboxBowl.Add(textBowl, 1, wx.CENTER)
        pnlBowl.SetSizer(vboxBowl)

        #bottom button
        pnlBottom = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlBottom, 1, wx.ALL | wx.EXPAND, 1)
        self.sldBottom = wx.Slider(pnlBottom, -1, motors["bottom"][1], motors["bottom"][0], motors["bottom"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textBottom = wx.StaticText(pnlBottom, -1, 'Bottom')
        vboxBottom = wx.BoxSizer(wx.VERTICAL)
        vboxBottom.Add(self.sldBottom, 1, wx.CENTER)
        vboxBottom.Add(textBottom, 1, wx.CENTER)
        pnlBottom.SetSizer(vboxBottom)

        #middle button
        pnlMiddle = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlMiddle, 1, wx.ALL | wx.EXPAND, 1)
        self.sldMiddle = wx.Slider(pnlMiddle, -1, motors["mid"][0], motors["mid"][0], motors["mid"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textMiddle = wx.StaticText(pnlMiddle, -1, 'Middle')
        vboxMiddle= wx.BoxSizer(wx.VERTICAL)
        vboxMiddle.Add(self.sldMiddle, 1, wx.CENTER)
        vboxMiddle.Add(textMiddle, 1, wx.CENTER)
        pnlMiddle.SetSizer(vboxMiddle)

        #top button
        pnlTop = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlTop, 1, wx.ALL | wx.EXPAND, 1)
        self.sldTop = wx.Slider(pnlTop, -1, motors["top"][0], motors["top"][0], motors["top"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textTop = wx.StaticText(pnlTop, -1, 'Top')
        vboxTop = wx.BoxSizer(wx.VERTICAL)
        vboxTop.Add(self.sldTop, 1, wx.CENTER)
        vboxTop.Add(textTop, 1, wx.CENTER)
        pnlTop.SetSizer(vboxTop)

        #head button
        pnlHead = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlHead, 1, wx.ALL | wx.EXPAND, 1)
        self.sldHead = wx.Slider(pnlHead, -1, motors["head"][0], motors["head"][0], motors["head"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textHead = wx.StaticText(pnlHead, -1, 'Head')
        vboxHead = wx.BoxSizer(wx.VERTICAL)
        vboxHead.Add(self.sldHead, 1, wx.CENTER)
        vboxHead.Add(textHead, 1, wx.CENTER)
        pnlHead.SetSizer(vboxHead)

        #red button
        pnlRed = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlRed, 1, wx.ALL | wx.EXPAND, 1)
        self.sldRed = wx.Slider(pnlRed, -1, 0, 0, 255, wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textRed = wx.StaticText(pnlRed, -1, 'Red')
        vboxRed = wx.BoxSizer(wx.VERTICAL)
        vboxRed.Add(self.sldRed, 1, wx.CENTER)
        vboxRed.Add(textRed, 1, wx.CENTER)
        pnlRed.SetSizer(vboxRed)

        #green button
        pnlGreen = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlGreen, 1, wx.ALL | wx.EXPAND, 1)
        self.sldGreen = wx.Slider(pnlGreen, -1, 0, 0, 255, wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textGreen = wx.StaticText(pnlGreen, -1, 'Green')
        vboxGreen = wx.BoxSizer(wx.VERTICAL)
        vboxGreen.Add(self.sldGreen, 1, wx.CENTER)
        vboxGreen.Add(textGreen, 1, wx.CENTER)
        pnlGreen.SetSizer(vboxGreen)

        #blue button
        pnlBlue = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        hboxcontrols.Add(pnlBlue, 1, wx.ALL | wx.EXPAND, 1)
        self.sldBlue = wx.Slider(pnlBlue, -1, 0, 0, 255, wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS)
        textBlue = wx.StaticText(pnlBlue, -1, 'Blue')
        vboxBlue = wx.BoxSizer(wx.VERTICAL)
        vboxBlue.Add(self.sldBlue, 1, wx.CENTER)
        vboxBlue.Add(textBlue, 1, wx.CENTER)
        pnlBlue.SetSizer(vboxBlue)


        #buttons
        pnlButtons = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
        vboxButton = wx.BoxSizer(wx.VERTICAL)
        
        gotoButton = wx.Button(pnlButtons, 7, 'Go To')
        vboxButton.Add(gotoButton, 1, wx.ALIGN_CENTER | wx.TOP, 15)
        wx.EVT_BUTTON(self, 7, self.OnGoto)

        savePositionButton = wx.Button(pnlButtons, 8, 'Save to list')
        vboxButton.Add(savePositionButton, 1, wx.ALIGN_CENTER | wx.TOP, 15)
        wx.EVT_BUTTON(self, 8, self.OnSavePosition)

        deletePositionButton = wx.Button(pnlButtons, 9, 'Delete from list')
        vboxButton.Add(deletePositionButton, 1, wx.ALIGN_CENTER | wx.TOP, 15)
        wx.EVT_BUTTON(self, 9, self.OnDeletePosition)

        playButton = wx.Button(pnlButtons, 10, 'Play')
        vboxButton.Add(playButton, 1, wx.ALIGN_CENTER | wx.TOP, 15)
        wx.EVT_BUTTON(self, 10, self.OnPlay)
        
        stopButton = wx.Button(pnlButtons, 11, 'Stop')
        vboxButton.Add(stopButton, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 15)
        wx.EVT_BUTTON(self, 11, self.OnStop)
        
        pnlButtons.SetSizer(vboxButton)
        
        #list of position
        self.positionList = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
        self.positionList.InsertColumn(0, 'bowl')
        self.positionList.InsertColumn(1, 'bottom')
        self.positionList.InsertColumn(2, 'middle')
        self.positionList.InsertColumn(3, 'top')
        self.positionList.InsertColumn(4, 'head')
        self.positionList.InsertColumn(5, 'red')
        self.positionList.InsertColumn(6, 'green')
        self.positionList.InsertColumn(7, 'blue')
        hboxlist.Add(self.positionList, 1, wx.EXPAND)

        hbox.Add(vbox, 5, wx.EXPAND | wx.ALL, 1)
        hbox.Add(pnlButtons, 1, wx.EXPAND | wx.ALL, 1)
        self.SetSize((800, 600))
        self.SetSizer(hbox)
        self.Centre()
예제 #24
0
    def __init__(self, parent, title, copyFrom, copyTo):
        """ Set up the Dialog Box and all GUI Widgets. """
        if (os.path.exists(copyFrom)):
            # Set up local variables
            self.parent = parent
            # Initialize Threaded File Copy object and the timer that updates the progress dialog
            self.threadedFileCopy = None
            self.timer = None

            size = (350, 200)
            # Create the Dialog Box itself, with no minimize/maximize/close buttons
            wx.Dialog.__init__(self,
                               parent,
                               -1,
                               title,
                               size=size,
                               style=wx.CAPTION)

            # Create a main VERTICAL sizer for the form
            mainSizer = wx.BoxSizer(wx.VERTICAL)

            # File label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("File: %s"), 'utf8')
            else:
                prompt = _("File: %s")
            # extract the file name...
            (dir, fileName) = os.path.split(copyFrom)
            self.destFileStr = os.path.join(copyTo, fileName)
            self.lblFile = wx.StaticText(self,
                                         -1,
                                         prompt % fileName,
                                         style=wx.ST_NO_AUTORESIZE)
            # Add the label to the Main Sizer
            mainSizer.Add(self.lblFile, 0, wx.ALL, 10)

            # Progress Bar
            self.progressBar = wx.Gauge(self,
                                        -1,
                                        100,
                                        style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
            # Add the element to the Main Sizer
            mainSizer.Add(self.progressBar, 1,
                          wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Create a Row Sizer
            r1Sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Bytes Transferred label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("%d bytes of %d transferred"), 'utf8')
            else:
                prompt = _("%d bytes of %d transferred")
            self.lblBytes = wx.StaticText(self,
                                          -1,
                                          prompt % (100000000, 100000000),
                                          style=wx.ST_NO_AUTORESIZE)
            # Add the label to the Row Sizer
            r1Sizer.Add(self.lblBytes, 5, wx.EXPAND)

            # Percent Transferred label
            self.lblPercent = wx.StaticText(self,
                                            -1,
                                            "%5.1d %%" % 1000.1,
                                            style=wx.ST_NO_AUTORESIZE
                                            | wx.ALIGN_RIGHT)
            # Add the Element to the Row Sizer
            r1Sizer.Add(self.lblPercent, 1, wx.ALIGN_RIGHT)

            # Add the Row Sizer to the Main Sizer
            mainSizer.Add(r1Sizer, 0,
                          wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Create a Row Sizer
            r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Elapsed Time label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("Elapsed Time: %d:%02d:%02d"), 'utf8')
            else:
                prompt = _("Elapsed Time: %d:%02d:%02d")
            self.lblElapsedTime = wx.StaticText(self,
                                                -1,
                                                prompt % (0, 0, 0),
                                                style=wx.ST_NO_AUTORESIZE)
            # Add the element to the Row Sizer
            r2Sizer.Add(self.lblElapsedTime, 0)

            # Add a spacer
            r2Sizer.Add((1, 0), 1, wx.EXPAND)

            # Remaining Time label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("Time Remaining: %d:%02d:%02d"), 'utf8')
            else:
                prompt = _("Time Remaining: %d:%02d:%02d")
            self.lblTimeRemaining = wx.StaticText(self,
                                                  -1,
                                                  prompt % (0, 0, 0),
                                                  style=wx.ST_NO_AUTORESIZE
                                                  | wx.ALIGN_RIGHT)
            # Add the element to the Row Sizer
            r2Sizer.Add(self.lblTimeRemaining, 0)

            # Add the Row Sizer to the Main Sizer
            mainSizer.Add(r2Sizer, 0,
                          wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Transfer Speed label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("Transfer Speed: %d k/sec"), 'utf8')
            else:
                prompt = _("Transfer Speed: %d k/sec")
            self.lblTransferSpeed = wx.StaticText(self,
                                                  -1,
                                                  prompt % 0,
                                                  style=wx.ST_NO_AUTORESIZE)
            # Add the element to the Main Sizer
            mainSizer.Add(self.lblTransferSpeed, 0,
                          wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Cancel Button
            self.btnCancel = wx.Button(self, wx.ID_CANCEL,
                                       _("Cancel Remaining Files"))
            # Add the element to the Main Sizer
            mainSizer.Add(self.btnCancel, 0,
                          wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

            # Attach the main sizer to the form
            self.SetSizer(mainSizer)
            # Turn Auto Layout on
            self.SetAutoLayout(True)
            # Lay out the form
            self.Layout()
            # Center on the Screen
            TransanaGlobal.CenterOnPrimary(self)
            # Initialize variables used in file transfer
            BytesRead = 0
            # "cancelled" is intialized to false.  If the user cancels the file transfer,
            # this variable gets set to true to signal the need to interrupt the transfer.
            self.cancelled = False
            # Note the starting time of the transfer for progress reporting purposes
            self.StartTime = time.time()

            self.Bind(wx.EVT_TIMER, self.UpdateDisplay)
            EVT_THREAD_COMPLETE(self, self.OnFileCopyComplete)

            # Create a timer used to update the Progress Dialog
            self.timer = wx.Timer(self)
            # Start the timer, firing it every half second
            self.timer.Start(500)

            self.size1 = os.stat(copyFrom)[6]
            self.threadedFileCopy = ThreadedFileCopy(self, copyFrom, copyTo)

            # Show the form
            self.ShowModal()
예제 #25
0
    def __init__(self, parent, headers, cfg, cfgGl, applyFunc):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           "Headers",
                           style=wx.DEFAULT_DIALOG_STYLE)

        self.headers = headers
        self.cfg = cfg
        self.cfgGl = cfgGl
        self.applyFunc = applyFunc

        # whether some events are blocked
        self.block = False

        self.hdrIndex = -1
        if len(self.headers.hdrs) > 0:
            self.hdrIndex = 0

        vsizer = wx.BoxSizer(wx.VERTICAL)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        hsizer.Add(wx.StaticText(self, -1, "Empty lines after headers:"), 0,
                   wx.ALIGN_CENTER_VERTICAL)

        self.elinesEntry = wx.SpinCtrl(self, -1)
        self.elinesEntry.SetRange(0, 5)
        wx.EVT_SPINCTRL(self, self.elinesEntry.GetId(), self.OnMisc)
        wx.EVT_KILL_FOCUS(self.elinesEntry, self.OnKillFocus)
        hsizer.Add(self.elinesEntry, 0, wx.LEFT, 10)

        vsizer.Add(hsizer)

        vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM,
                   10)

        tmp = wx.StaticText(self, -1, "Strings:")
        vsizer.Add(tmp)

        self.stringsLb = wx.ListBox(self, -1, size=(200, 100))
        vsizer.Add(self.stringsLb, 0, wx.EXPAND)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        self.addBtn = gutil.createStockButton(self, "Add")
        hsizer.Add(self.addBtn)
        wx.EVT_BUTTON(self, self.addBtn.GetId(), self.OnAddString)
        gutil.btnDblClick(self.addBtn, self.OnAddString)

        self.delBtn = gutil.createStockButton(self, "Delete")
        hsizer.Add(self.delBtn, 0, wx.LEFT, 10)
        wx.EVT_BUTTON(self, self.delBtn.GetId(), self.OnDeleteString)
        gutil.btnDblClick(self.delBtn, self.OnDeleteString)

        vsizer.Add(hsizer, 0, wx.TOP, 5)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        hsizer.Add(wx.StaticText(self, -1, "Text:"), 0,
                   wx.ALIGN_CENTER_VERTICAL)

        self.textEntry = wx.TextCtrl(self, -1)
        hsizer.Add(self.textEntry, 1, wx.LEFT, 10)
        wx.EVT_TEXT(self, self.textEntry.GetId(), self.OnMisc)

        vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20)

        vsizer.Add(
            wx.StaticText(self, -1,
                          "'${PAGE}' will be replaced by the page number."), 0,
            wx.ALIGN_CENTER | wx.TOP, 5)

        hsizerTop = wx.BoxSizer(wx.HORIZONTAL)

        gsizer = wx.FlexGridSizer(3, 2, 5, 0)

        gsizer.Add(wx.StaticText(self, -1, "Header line:"), 0,
                   wx.ALIGN_CENTER_VERTICAL)

        self.lineEntry = wx.SpinCtrl(self, -1)
        self.lineEntry.SetRange(1, 5)
        wx.EVT_SPINCTRL(self, self.lineEntry.GetId(), self.OnMisc)
        wx.EVT_KILL_FOCUS(self.lineEntry, self.OnKillFocus)
        gsizer.Add(self.lineEntry)

        gsizer.Add(wx.StaticText(self, -1, "X offset (characters):"), 0,
                   wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10)

        self.xoffEntry = wx.SpinCtrl(self, -1)
        self.xoffEntry.SetRange(-100, 100)
        wx.EVT_SPINCTRL(self, self.xoffEntry.GetId(), self.OnMisc)
        wx.EVT_KILL_FOCUS(self.xoffEntry, self.OnKillFocus)
        gsizer.Add(self.xoffEntry)

        gsizer.Add(wx.StaticText(self, -1, "Alignment:"), 0,
                   wx.ALIGN_CENTER_VERTICAL)
        self.alignCombo = wx.ComboBox(self, -1, style=wx.CB_READONLY)

        for it in [("Left", util.ALIGN_LEFT), ("Center", util.ALIGN_CENTER),
                   ("Right", util.ALIGN_RIGHT)]:
            self.alignCombo.Append(it[0], it[1])

        gsizer.Add(self.alignCombo)
        wx.EVT_COMBOBOX(self, self.alignCombo.GetId(), self.OnMisc)

        hsizerTop.Add(gsizer)

        bsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Style"),
                                   wx.HORIZONTAL)

        vsizer2 = wx.BoxSizer(wx.VERTICAL)

        # wxGTK adds way more space by default than wxMSW between the
        # items, have to adjust for that
        pad = 0
        if misc.isWindows:
            pad = 5

        self.addCheckBox("Bold", self, vsizer2, pad)
        self.addCheckBox("Italic", self, vsizer2, pad)
        self.addCheckBox("Underlined", self, vsizer2, pad)

        bsizer.Add(vsizer2)

        hsizerTop.Add(bsizer, 0, wx.LEFT, 40)

        vsizer.Add(hsizerTop, 0, wx.TOP, 20)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        hsizer.Add((1, 1), 1)

        previewBtn = gutil.createStockButton(self, "Preview")
        hsizer.Add(previewBtn)

        applyBtn = gutil.createStockButton(self, "Apply")
        hsizer.Add(applyBtn, 0, wx.LEFT, 10)

        cancelBtn = gutil.createStockButton(self, "Cancel")
        hsizer.Add(cancelBtn, 0, wx.LEFT, 10)

        okBtn = gutil.createStockButton(self, "OK")
        hsizer.Add(okBtn, 0, wx.LEFT, 10)

        vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 20)

        util.finishWindow(self, vsizer)

        wx.EVT_BUTTON(self, previewBtn.GetId(), self.OnPreview)
        wx.EVT_BUTTON(self, applyBtn.GetId(), self.OnApply)
        wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel)
        wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK)

        wx.EVT_LISTBOX(self, self.stringsLb.GetId(), self.OnStringsLb)

        # list of widgets that are specific to editing the selected string
        self.widList = [
            self.textEntry, self.xoffEntry, self.alignCombo, self.lineEntry,
            self.boldCb, self.italicCb, self.underlinedCb
        ]

        self.updateGui()

        self.textEntry.SetFocus()
예제 #26
0
 def buildControls(self):
     mainSizer = wx.BoxSizer(wx.VERTICAL)
     self.panel = InterfaceListPanel(self)
     mainSizer.Add(self.panel, 1, wx.EXPAND)
     self.SetSizer(mainSizer)
     wx.EVT_BUTTON(self, wx.ID_OK, self.onCommit)
예제 #27
0
    def __init__(self, parent, title, fileName, fileSize, localDir, connectionID, collectionName, direction, bufferSize):
        """ Set up the Dialog Box and all GUI Widgets. """
        # Set up local variables
        self.parent = parent
        self.fileSize = fileSize
        self.bufferSize = int(bufferSize)

        # Create the Dialog Box itself, with no minimize/maximize/close buttons
        wx.Dialog.__init__(self, parent, -1, title, size = (350,200), style=wx.CAPTION)

        # Create a main VERTICAL sizer for the form
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # File label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("File: %s"), 'utf8')
        else:
            prompt = _("File: %s")
        self.lblFile = wx.StaticText(self, -1, prompt % fileName, style=wx.ST_NO_AUTORESIZE)
        # Add the label to the Main Sizer
        mainSizer.Add(self.lblFile, 0, wx.ALL, 10)

        # Progress Bar
        self.progressBar = wx.Gauge(self, -1, 100, style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
        # Add the element to the Main Sizer
        mainSizer.Add(self.progressBar, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        # Create a Row Sizer
        r1Sizer = wx.BoxSizer(wx.HORIZONTAL)
        
        # Bytes Transferred label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("%d bytes of %d transferred"), 'utf8')
        else:
            prompt = _("%d bytes of %d transferred")
        self.lblBytes = wx.StaticText(self, -1, prompt % (100000000, 100000000), style=wx.ST_NO_AUTORESIZE)
        # Add the label to the Row Sizer
        r1Sizer.Add(self.lblBytes, 5, wx.EXPAND)

        # Percent Transferred label
        self.lblPercent = wx.StaticText(self, -1, "%5.1d %%" % 1000.1, style=wx.ST_NO_AUTORESIZE | wx.ALIGN_RIGHT)
        # Add the Element to the Row Sizer
        r1Sizer.Add(self.lblPercent, 1, wx.ALIGN_RIGHT)

        # Add the Row Sizer to the Main Sizer
        mainSizer.Add(r1Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        # Create a Row Sizer
        r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Elapsed Time label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("Elapsed Time: %d:%02d:%02d"), 'utf8')
        else:
            prompt = _("Elapsed Time: %d:%02d:%02d")
        self.lblElapsedTime = wx.StaticText(self, -1, prompt % (0, 0, 0), style=wx.ST_NO_AUTORESIZE)
        # Add the element to the Row Sizer
        r2Sizer.Add(self.lblElapsedTime, 0)

        # Add a spacer
        r2Sizer.Add((1, 0), 1, wx.EXPAND)

        # Remaining Time label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("Time Remaining: %d:%02d:%02d"), 'utf8')
        else:
            prompt = _("Time Remaining: %d:%02d:%02d")
        self.lblTimeRemaining = wx.StaticText(self, -1, prompt % (0, 0, 0), style=wx.ST_NO_AUTORESIZE | wx.ALIGN_RIGHT)
        # Add the element to the Row Sizer
        r2Sizer.Add(self.lblTimeRemaining, 0)

        # Add the Row Sizer to the Main Sizer
        mainSizer.Add(r2Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        # Transfer Speed label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("Transfer Speed: %d k/sec"), 'utf8')
        else:
            prompt = _("Transfer Speed: %d k/sec")
        self.lblTransferSpeed = wx.StaticText(self, -1, prompt % 0, style=wx.ST_NO_AUTORESIZE)
        # Add the element to the Main Sizer
        mainSizer.Add(self.lblTransferSpeed, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        # Cancel Button
        btn = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
        # Add the element to the Main Sizer
        mainSizer.Add(btn, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        # Attach the main sizer to the form
        self.SetSizer(mainSizer)
        # Turn Auto Layout on
        self.SetAutoLayout(True)
        # Lay out the form
        self.Layout()
        # Center on the Screen
        self.CenterOnScreen()
        # Show the form
        self.Show()
        # make sure the loca directory ends with the proper path seperator character
        if localDir[-1] != os.sep:
            localDir = localDir + os.sep
        # Initialize variables used in file transfer
        BytesRead = 0
        # "cancelled" is intialized to false.  If the user cancels the file transfer,
        # this variable gets set to true to signal the need to interrupt the transfer.
        self.cancelled = False
        # Note the starting time of the transfer for progress reporting purposes
        self.StartTime = time.time()

        if "__WXMSW__" in wx.PlatformInfo:
            srb = ctypes.cdll.srbClient
        else:
            srb = ctypes.cdll.LoadLibrary("srbClient.dylib")

        # If we are sending files from the SRB to the local File System...
        if direction == srb_DOWNLOAD:
            self.SetTitle(_('Downloading . . .'))

            if 'unicode' in wx.PlatformInfo:
                tmpCollectionName = collectionName.encode(TransanaGlobal.encoding)
                tmpFileName = fileName.encode(TransanaGlobal.encoding)
                
            # Open the proper File Object on the SRB
            FileResult = srb.srbDaiObjOpen(connectionID, tmpCollectionName, tmpFileName, 0)

            # Make sure the object opened correctly
            if FileResult < 0:
                # If the file object did not open correctly, display an Error message.
                self.parent.srbErrorMessage(FileResult)
            else:
                # Create and Open a local binary file for writing to accept the data being sent from the SRB
                outputFile = file(localDir + fileName, 'wb', self.bufferSize)

                # While there is data, read it from the SRB and write it to the local file system.
                # ("while 1" tells the program to just keep looping until a "break" command is triggered.)
                while True:
                    BufSize = self.bufferSize
                    # Initialize the buffer to empty spaces to prepare for the SRB Call
                    Buf = ' ' * BufSize
                    # Get a block of data from the SRB and put it in the Buffer
                    fileWrite = srb.srbDaiObjRead(connectionID, FileResult, Buf, BufSize)
                    # The SRB returns the number of bytes read or an error message (negative value)
                    if fileWrite < 0:
                        # A SRB Error has occurred
                        self.parent.srbErrorMessage(fileWrite)
                    elif (fileWrite == 0) or self.cancelled:
                        # The file has no more data, so we need to break out of the while loop, OR
                        # the user has requested to cancel the file transfer.
                        break
                    else:
                        # Data is read from the file
                        # We are tracking the number of bytes read for progress reporting purposes,
                        # and so that we know what size buffer we need for reading more data
                        BytesRead = BytesRead + fileWrite

                        # Reduce the size of the Buffer to match the data return size.  (We were getting
                        # incomplete downloads without this step!)
                        if fileWrite < self.bufferSize:
                            Buf = Buf[:fileWrite]

                        try:
                            # Let's write the data in the buffer to the local file
                            outputFile.write(Buf)
                        except exceptions.IOError, (errNum, errStr):
                            # The transfer must be interrupted
                            self.cancelled = True
                            # To display an error message, we need to import the error dialog
                            import Dialogs
                            # Create and display the error message
                            errDlg = Dialogs.ErrorDialog(self, errStr)
                            errDlg.ShowModal()
                            errDlg.Destroy()

                        # Let's provide the user with feedback as we read the file
                        self.UpdateDisplay(BytesRead)

                # When all the data has been read (or the transfer cancelled), we can close the local file.
                # Before we do, let's flush the file in case there is still data in the buffer.
                outputFile.flush()
                outputFile.close()

            # We can now close the SRB Data object (file)
            TempInt = srb.srbDaiObjClose(connectionID, FileResult)
            # srbDaiObjClose Error Checking
            if TempInt < 0:
                self.parent.srbErrorMessage(TempInt)
예제 #28
0
    def __init__(self, parent, file_contents):
        #set the title to the file name
        frame_title = "%s - Data Select - %s" % (file_contents.filename,
                                                 avoplot.PROG_SHORT_NAME)
        wx.Dialog.__init__(self,
                           parent,
                           wx.ID_ANY,
                           frame_title,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.parent = parent
        self.filename = file_contents.filename

        #set up the icon for the frame
        self.SetIcon(wx.ArtProvider.GetIcon("avoplot"))

        #create top level panel to hold all frame elements
        top_panel = wx.Panel(self, wx.ID_ANY)

        #create top level sizer to contain all frame elements
        topsizer = wx.BoxSizer(wx.VERTICAL)
        vsizer = wx.BoxSizer(wx.VERTICAL)
        topsizer.AddSpacer(5)
        topsizer.Add(vsizer, 1, wx.EXPAND)

        #create all the frame elements
        self.splitter = wx.SplitterWindow(top_panel, -1)
        self.splitter.SetMinimumPaneSize(50)

        self.file_contents_panel = FileContentsPanel(self.splitter,
                                                     file_contents)
        self.data_series_panel = DataSeriesSelectPanel(self.splitter, self,
                                                       file_contents)

        width, sash_pos = self.data_series_panel.GetSizeTuple()
        self.splitter.SplitHorizontally(self.file_contents_panel,
                                        self.data_series_panel, -2 * sash_pos)

        vsizer.Add(self.splitter, 1, wx.EXPAND | wx.ALL, border=5)
        self.SetSize((width + 60, -1))

        #create main buttons
        buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.plot_button = wx.Button(top_panel, wx.ID_ANY, "Plot")
        self.cancel_button = wx.Button(top_panel, wx.ID_ANY, "Cancel")
        buttons_sizer.Add(self.cancel_button, 1,
                          wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM)
        buttons_sizer.Add(self.plot_button, 1,
                          wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM)
        wx.EVT_BUTTON(self, self.plot_button.GetId(), self.on_plot)
        wx.EVT_BUTTON(self, self.cancel_button.GetId(), self.on_cancel)

        vsizer.Add(buttons_sizer,
                   0,
                   wx.ALL | wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT,
                   border=10)

        #configure layout and position
        top_panel.SetSizer(topsizer)
        topsizer.Fit(top_panel)
        top_panel.SetAutoLayout(True)
        self.Center(wx.BOTH)

        self.SendSizeEvent()  #force redraw (only needed for windows)
        self.splitter.SetSashGravity(0.5)
        self.Show()
예제 #29
0
    def make_widgets(self):
        self.lblLattice = wx.StaticText(self, -1, "Lattice", size=(80, -1))
        self.cboUCtype = wx.ComboBox(self,
                                     -1,
                                     choices=[
                                         "SC", "FCC", "BCC", "HCP", "Diamond",
                                         "bTin", "Graphite", "Hexag", "NaCl",
                                         "CsCl", "Cubic ZnS", "Hex Zns"
                                     ],
                                     style=wx.CB_DROPDOWN)

        self.lblAtomtype = wx.StaticText(self, -1, "Atom Types", size=(80, -1))
        self.txtAtomType1 = wx.TextCtrl(self, -1, "")
        self.txtAtomType2 = wx.TextCtrl(self, -1, "")

        self.lblACA = wx.StaticText(self, -1, "A, C/A", size=(80, -1))
        self.txtAentry = wx.TextCtrl(self, -1, "")
        self.txtCAentry = wx.TextCtrl(self, -1, "")

        self.btnCancel = wx.Button(self, -1, "Cancel")
        self.btnBuild = wx.Button(self, -1, "Build")
        self.btnBuild.SetDefault()

        szrCrystalBuilder = wx.BoxSizer(wx.VERTICAL)
        szrLattice = wx.BoxSizer(wx.HORIZONTAL)
        szrAtomTypes = wx.BoxSizer(wx.HORIZONTAL)
        szrACA = wx.BoxSizer(wx.HORIZONTAL)
        szrButton = wx.BoxSizer(wx.HORIZONTAL)
        szrLattice.Add(
            self.lblLattice, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrLattice.Add(
            self.cboUCtype, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrAtomTypes.Add(
            self.lblAtomtype, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrAtomTypes.Add(
            self.txtAtomType1, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrAtomTypes.Add(
            self.txtAtomType2, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrACA.Add(
            self.lblACA, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrACA.Add(
            self.txtAentry, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrACA.Add(
            self.txtCAentry, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrButton.Add(
            self.btnBuild, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrButton.Add(
            self.btnCancel, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrCrystalBuilder.Add(szrLattice, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                              0)
        szrCrystalBuilder.Add(szrAtomTypes, 0,
                              wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)
        szrCrystalBuilder.Add(szrACA, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)
        szrCrystalBuilder.Add(
            szrButton, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        self.SetAutoLayout(1)
        self.SetSizer(szrCrystalBuilder)
        szrCrystalBuilder.Fit(self)
        szrCrystalBuilder.SetSizeHints(self)
        self.cboUCtype.SetSelection(0)
        wx.EVT_BUTTON(self, self.btnBuild.GetId(), self.do_build)
        wx.EVT_BUTTON(self, self.btnCancel.GetId(), self.cancel)
        return
예제 #30
0
    def make_widgets(self):
        self.lblCleavage = wx.StaticText(self,
                                         -1,
                                         "Cleavage Direction",
                                         size=(110, -1))
        self.cboCleavage = wx.ComboBox(self,
                                       -1,
                                       choices=["C", "B", "A"],
                                       style=wx.CB_DROPDOWN)
        self.lblSlabDepth = wx.StaticText(self,
                                          -1,
                                          "Slab Depth",
                                          size=(110, -1))
        self.txtSlabDepth = wx.TextCtrl(self, -1, "")
        self.lblVacuum = wx.StaticText(self,
                                       -1,
                                       "Vacuum Amount",
                                       size=(110, -1))
        self.txtVacuum = wx.TextCtrl(self, -1, "")

        self.btnCancel = wx.Button(self, -1, "Cancel")
        self.btnBuildSlab = wx.Button(self, -1, "Build")
        self.btnBuildSlab.SetDefault()

        szrSlab = wx.BoxSizer(wx.VERTICAL)
        szrCleavage = wx.BoxSizer(wx.HORIZONTAL)
        szrSlabDepth = wx.BoxSizer(wx.HORIZONTAL)
        szrVacuum = wx.BoxSizer(wx.HORIZONTAL)
        szrButton = wx.BoxSizer(wx.HORIZONTAL)
        szrCleavage.Add(
            self.lblCleavage, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrCleavage.Add(
            self.cboCleavage, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrSlabDepth.Add(
            self.lblSlabDepth, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrSlabDepth.Add(
            self.txtSlabDepth, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrVacuum.Add(
            self.lblVacuum, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrVacuum.Add(
            self.txtVacuum, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrButton.Add(
            self.btnBuildSlab, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrButton.Add(
            self.btnCancel, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        szrSlab.Add(szrCleavage, 0, 0, 0)
        szrSlab.Add(szrSlabDepth, 0, 0, 0)
        szrSlab.Add(szrVacuum, 0, 0, 0)
        szrSlab.Add(
            szrButton, 0,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetAutoLayout(1)
        self.SetSizer(szrSlab)
        szrSlab.Fit(self)
        szrSlab.SetSizeHints(self)
        self.cboCleavage.SetSelection(0)
        wx.EVT_BUTTON(self, self.btnBuildSlab.GetId(), self.do_slab_build)
        wx.EVT_BUTTON(self, self.btnCancel.GetId(), self.cancel)
        return