예제 #1
0
class SummaryPage(parentpage):
    def __init__(self, parent):
        super(SummaryPage, self).__init__(parent, 'Selection Summary')

    def GetMyControls(self):
        vbs = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Selection Summary:'),
                                wx.VERTICAL)
        self.summary = ExpandoTextCtrl(self, -1, '')
        self.summary.SetBackgroundColour(self.GetBackgroundColour())
        vbs.Add(self.summary, 0, wx.EXPAND | wx.ALL, 5)
        self._box = vbs
        return vbs

    def set(self, data):
        text = ['Name:\t%s' % data.get('name', '')]
        text.append('Dir:\t%s' % data.get('path', ''))
        if data.get('currentsettings', False):
            text.append('Use current BitPim settings.')
        else:
            text.append('Use default BitPim settings.')
        if guihelper.IsMSWindows():
            if data.get('desktop', False):
                text.append('Create a shortcut on your Desktop.')
            if data.get('startmenu', False):
                text.append('Create a shortcut in your Start Menu.')
        self.summary.SetValue('\n\n'.join(text))
예제 #2
0
파일: dialogs.py 프로젝트: jomason/omnivore
 def create_expando(self, key, label, choices=None):
     sizer = self.GetSizer()
     status = ExpandoTextCtrl(self,
                              style=wx.ALIGN_LEFT | wx.TE_READONLY
                              | wx.NO_BORDER)
     attr = self.GetDefaultAttributes()
     status.SetBackgroundColour(attr.colBg)
     sizer.Add(status, 1, wx.ALL | wx.EXPAND, self.border)
     return status
예제 #3
0
class ImportSourcePage(setphone_wizard.MyPage):
    def __init__(self, parent):
        self._source = None
        super(ImportSourcePage, self).__init__(parent, 'Select Import Source')

    def GetMyControls(self):
        vbs = wx.BoxSizer(wx.VERTICAL)
        vbs.Add(wx.StaticText(self, -1, 'Source of data:'), 0,
                wx.ALL | wx.EXPAND, 5)
        self._source_lbl = ExpandoTextCtrl(self, -1, '', style=wx.TE_READONLY)
        self._source_lbl.SetBackgroundColour(self.GetBackgroundColour())
        vbs.Add(self._source_lbl, 0, wx.ALL | wx.EXPAND, 5)

        _btn = wx.Button(self, -1, 'Browse')
        wx.EVT_BUTTON(self, _btn.GetId(), self._OnBrowse)
        vbs.Add(_btn, 0, wx.ALL, 5)
        return vbs

    def setlabel(self):
        self._source_lbl.SetValue(self._source.name())

    @guihelper.BusyWrapper
    def _OnBrowse(self, _=None):
        if not self._source:
            return
        self._source.browse(self)
        self.setlabel()

    def ok(self):
        return self._source and self._source.get()

    def get(self, data):
        data['source_obj'] = self._source
        data['source_id'] = self._source.id
        data['imported'] = False

    def set(self, data):
        self._source = data['source_obj']
        if self._source:
            if data.has_key('source_id'):
                self._source.id = data['source_id']
            self.setlabel()

    def GetActiveDatabase(self):
        return self.GetParent().GetActiveDatabase()
예제 #4
0
class PathPage(parentpage):
    def __init__(self, parent):
        super(PathPage, self).__init__(parent, 'Select New Storage Dir')
        if guihelper.IsMSWindows():
            shell = client.Dispatch("WScript.Shell")
            self.defaultdir = os.path.join(shell.SpecialFolders("MyDocuments"),
                                           'Phones')
        else:
            self.defaultdir = os.path.expanduser('~/Phones')

    def GetMyControls(self):
        vbs = wx.BoxSizer(wx.VERTICAL)
        vbs.Add(wx.StaticText(self, -1, 'Storage Dir:'), 0, wx.EXPAND | wx.ALL,
                5)
        self.path = ExpandoTextCtrl(self, -1, '', style=wx.TE_READONLY)
        self.path.SetBackgroundColour(self.GetBackgroundColour())
        vbs.Add(self.path, 0, wx.EXPAND | wx.ALL, 5)
        btn = wx.Button(self, -1, 'Browse')
        wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse)
        vbs.Add(btn, 0, wx.ALL, 5)
        return vbs

    def ok(self):
        return bool(self.path.GetValue())

    def get(self, data):
        data['path'] = self.path.GetValue()

    def set(self, data):
        path = data.get('path', '')
        if not path:
            path = os.path.join(self.defaultdir, data.get('name', ''))
        self.path.SetValue(path)

    def OnBrowse(self, _):
        with guihelper.WXDialogWrapper(
                wx.DirDialog(self,
                             defaultPath=self.path.GetLabel(),
                             style=wx.DD_NEW_DIR_BUTTON),
                True) as (dlg, retcode):
            if retcode == wx.ID_OK:
                self.path.SetValue(dlg.GetPath())
예제 #5
0
    def addRow(self, row, rowLabel=None):
        """Add one row of info, either header (col names) or normal data

        Adds items sequentially; FlexGridSizer moves to next row automatically
        """
        labelBox = wx.BoxSizer(wx.HORIZONTAL)
        if not rowLabel:
            if sys.platform == 'darwin':
                self.SetWindowVariant(variant=wx.WINDOW_VARIANT_SMALL)
            label = _translate('cond %s:') % str(row + 1 -
                                                 int(self.hasHeader)).zfill(2)
            rowLabel = wx.StaticText(self, -1, label=label)
            rowLabel.SetForegroundColour(darkgrey)
            if sys.platform == 'darwin':
                self.SetWindowVariant(variant=wx.WINDOW_VARIANT_NORMAL)
        labelBox.Add(rowLabel, 1, flag=wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM)
        self.sizer.Add(labelBox, 1, flag=wx.ALIGN_CENTER)
        lastRow = []
        for col in range(self.cols):
            # get the item, as unicode for display purposes:
            if len(str(self.grid[row][col])):  # want 0, for example
                item = str(self.grid[row][col])
            else:
                item = u''
            # make a textbox:
            field = ExpandoTextCtrl(self,
                                    -1,
                                    item,
                                    size=(self.colSizes[col], 20))
            field.Bind(EVT_ETC_LAYOUT_NEEDED, self.onNeedsResize)
            field.SetMaxHeight(100)  # ~ 5 lines
            if self.hasHeader and row == 0:
                # add a default column name (header) if none provided
                header = self.grid[0]
                if item.strip() == '':
                    c = col
                    while self.colName(c) in header:
                        c += 1
                    field.SetValue(self.colName(c))
                field.SetForegroundColour(darkblue)  # dark blue
                # or (self.parent and
                if not valid_var_re.match(field.GetValue()):
                    # self.parent.exp.namespace.exists(field.GetValue()) ):
                    # was always red when preview .xlsx file -- in
                    # namespace already is fine
                    if self.fixed:
                        field.SetForegroundColour("Red")
                field.SetToolTip(
                    wx.ToolTip(
                        _translate(
                            'Should be legal as a variable name (alphanumeric)'
                        )))
                field.Bind(wx.EVT_TEXT, self.checkName)
            elif self.fixed:
                field.SetForegroundColour(darkgrey)
                field.SetBackgroundColour(white)

            # warn about whitespace unless will be auto-removed. invisible,
            # probably spurious:
            if (self.fixed or not self.clean) and item != item.strip():
                field.SetForegroundColour('Red')
                # also used in show():
                self.warning = _translate('extra white-space')
                field.SetToolTip(wx.ToolTip(self.warning))
            if self.fixed:
                field.Disable()
            lastRow.append(field)
            self.sizer.Add(field, 1)
        self.inputFields.append(lastRow)
        if self.hasHeader and row == 0:
            self.header = lastRow
예제 #6
0
class messagePanel(wx.Panel):
    def __init__(self, parent, messageData, nickname=u'王小明'):

        #计算合适的宽度
        border_width = 18
        parent_width, parent_height = parent.GetSize()
        max_width = parent_width * 0.5
        min_width = wxtl.GetTextDisplayLen(nickname) + border_width
        '''
        panel = wx.Panel(parent)
        panel_sizer = wx.BoxSizer()
        panel.SetSizer(panel_sizer)
        text = wx.StaticText(panel, wx.ID_ANY, label = messageData)
        panel_sizer.Add(text, 1, wx.EXPAND)
        text_width, text_height =  panel.GetBestSize()
        panel.Destroy()
        '''

        text_width = wxtl.GetTextDisplayLen(messageData)

        if text_width > max_width:
            width = max_width
        elif text_width < min_width:
            width = min_width
        else:
            width = text_width + border_width

        print text_width
        print min_width
        print width

        #开始初始化用于显示消息的panel
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=(width, -1),
                          style=wx.TAB_TRAVERSAL)

        self.SetForegroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND))

        message_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, nickname), wx.VERTICAL)

        self.m_textCtrl7 = ExpandoTextCtrl(self,
                                           wx.ID_ANY,
                                           value=messageData,
                                           style=wx.TE_MULTILINE | wx.NO_BORDER
                                           | wx.TE_READONLY)
        self.m_textCtrl7.SetForegroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
        self.m_textCtrl7.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND))
        #self.m_textCtrl7.Enable(False)

        message_sizer.Add(self.m_textCtrl7, 1, wx.ALL | wx.EXPAND, 7)

        self.SetSizer(message_sizer)
        self.Sizer.Fit(self)

        self.Layout()

    def __del__(self):
        pass