当前位置: 首页>>代码示例>>Python>>正文


Python wx.xrc方法代码示例

本文整理汇总了Python中wx.xrc方法的典型用法代码示例。如果您正苦于以下问题:Python wx.xrc方法的具体用法?Python wx.xrc怎么用?Python wx.xrc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wx的用法示例。


在下文中一共展示了wx.xrc方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def __init__(self, parent, value):
        # Load from resource
        pre = wx.PreDialog()
        g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT')
        self.PostCreate(pre)
        self.list = xrc.XRCCTRL(self, 'LIST')
        # Set list items
        for v in value:
            self.list.Append(v)
        self.SetAutoLayout(True)
        self.GetSizer().Fit(self)
        # Callbacks
        self.ID_BUTTON_APPEND = xrc.XRCID('BUTTON_APPEND')
        self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE')
        self.ID_BUTTON_UP = xrc.XRCID('BUTTON_UP')
        self.ID_BUTTON_DOWN = xrc.XRCID('BUTTON_DOWN')
        wx.EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
        wx.EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
        wx.EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
        wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
        wx.EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) 
开发者ID:andreas-p,项目名称:admin4,代码行数:25,代码来源:params.py

示例2: OnOpen

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnOpen(self, evt):
        if not self.AskSave(): return
        dlg = wx.FileDialog(self, 'Open', os.path.dirname(self.dataFile),
                           '', '*.xrc', wx.OPEN | wx.CHANGE_DIR)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            self.SetStatusText('Loading...')
            wx.BeginBusyCursor()
            try:
                if self.Open(path):
                    self.SetStatusText('Data loaded')
                else:
                    self.SetStatusText('Failed')
                self.SaveRecent(path)
            finally:
                wx.EndBusyCursor()
        dlg.Destroy() 
开发者ID:andreas-p,项目名称:admin4,代码行数:19,代码来源:xrced.py

示例3: OnBang

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnBang(self, event):
        bang_count = xrc.XRCCTRL(self.frame, "bang_count")
        bangs = bang_count.GetValue()
        bangs = int(bangs) + 1
        bang_count.SetValue(str(bangs)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:7,代码来源:embedding_in_wx3_sgskip.py

示例4: OnButtonChoices

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnButtonChoices(self, evt):
        dlg = g.frame.res.LoadDialog(self, 'DIALOG_CHOICES')
        if self.GetName() == 'flag':  dlg.SetTitle('Sizer item flags')
        elif self.GetName() == 'style':  dlg.SetTitle('Window styles')
        elif self.GetName() == 'exstyle':  dlg.SetTitle('Extended window styles')
        listBox = xrc.XRCCTRL(dlg, 'CHECKLIST')
        listBox.InsertItems(self.values, 0)
        value = map(string.strip, self.text.GetValue().split('|'))
        if value == ['']: value = []
        ignored = []
        for i in value:
            try:
                listBox.Check(self.values.index(i))
            except ValueError:
                # Try to find equal
                if self.equal.has_key(i):
                    listBox.Check(self.values.index(self.equal[i]))
                else:
                    print 'WARNING: unknown flag: %s: ignored.' % i
                    ignored.append(i)
        if dlg.ShowModal() == wx.ID_OK:
            value = []
            for i in range(listBox.GetCount()):
                if listBox.IsChecked(i):
                    value.append(self.values[i])
            # Add ignored flags
            value.extend(ignored)
            self.SetValue('|'.join(value))
            self.SetModified()
        dlg.Destroy() 
开发者ID:andreas-p,项目名称:admin4,代码行数:32,代码来源:params.py

示例5: OnButtonChoicesBoth

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnButtonChoicesBoth(self, evt):
        dlg = g.frame.res.LoadDialog(self, 'DIALOG_STYLES')
        listBoxSpecific = xrc.XRCCTRL(dlg, 'CHECKLIST_SPECIFIC')
        listBoxSpecific.InsertItems(self.valuesSpecific, 0)
        listBoxGeneric = xrc.XRCCTRL(dlg, 'CHECKLIST_GENERIC')
        listBoxGeneric.InsertItems(self.valuesGeneric, 0)
        value = map(string.strip, self.text.GetValue().split('|'))
        if value == ['']: value = []
        # Set specific styles
        value2 = []                     # collect generic and ignored here
        for i in value:
            try:
                listBoxSpecific.Check(self.valuesSpecific.index(i))
            except ValueError:
                # Try to find equal
                if self.equal.has_key(i):
                    listBoxSpecific.Check(self.valuesSpecific.index(self.equal[i]))
                else:
                    value2.append(i)
        ignored = []
        # Set generic styles, collect non-standart values
        for i in value2:
            try:
                listBoxGeneric.Check(self.valuesGeneric.index(i))
            except ValueError:
                # Try to find equal
                if self.equal.has_key(i):
                    listBoxGeneric.Check(self.valuesGeneric.index(self.equal[i]))
                else:
                    print 'WARNING: unknown flag: %s: ignored.' % i
                    ignored.append(i)
        if dlg.ShowModal() == wx.ID_OK:
            value = [self.valuesSpecific[i]
                     for i in range(listBoxSpecific.GetCount())
                     if listBoxSpecific.IsChecked(i)] + \
                     [self.valuesGeneric[i]
                      for i in range(listBoxGeneric.GetCount())
                      if listBoxGeneric.IsChecked(i)] + ignored
            self.SetValue('|'.join(value))
            self.SetModified()
        dlg.Destroy() 
开发者ID:andreas-p,项目名称:admin4,代码行数:43,代码来源:params.py

示例6: OnButtonEdit

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnButtonEdit(self, evt):
        dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT')
        textCtrl = xrc.XRCCTRL(dlg, 'TEXT')
        textCtrl.SetValue(self.text.GetValue())
        if dlg.ShowModal() == wx.ID_OK:
            self.text.SetValue(textCtrl.GetValue())
            self.SetModified()
        dlg.Destroy() 
开发者ID:andreas-p,项目名称:admin4,代码行数:10,代码来源:params.py

示例7: __init__

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def __init__(self, parent, cfg, dataFile):
        pre = wx.PreDialog()
        g.frame.res.LoadOnDialog(pre, parent, "PYTHON_OPTIONS")
        self.PostCreate(pre)

        self.cfg = cfg
        self.dataFile = dataFile

        self.AutoGenerateCB = xrc.XRCCTRL(self, "AutoGenerateCB")
        self.EmbedCB = xrc.XRCCTRL(self, "EmbedCB")
        self.GettextCB = xrc.XRCCTRL(self, "GettextCB")
        self.MakeXRSFileCB = xrc.XRCCTRL(self, "MakeXRSFileCB")
        self.FileNameTC = xrc.XRCCTRL(self, "FileNameTC")
        self.BrowseBtn = xrc.XRCCTRL(self, "BrowseBtn")
        self.GenerateBtn = xrc.XRCCTRL(self, "GenerateBtn")
        self.SaveOptsBtn = xrc.XRCCTRL(self, "SaveOptsBtn")

        self.Bind(wx.EVT_BUTTON, self.OnBrowse, self.BrowseBtn)
        self.Bind(wx.EVT_BUTTON, self.OnGenerate, self.GenerateBtn)
        self.Bind(wx.EVT_BUTTON, self.OnSaveOpts, self.SaveOptsBtn)

        if self.cfg.Read("filename", "") != "":
            self.FileNameTC.SetValue(self.cfg.Read("filename"))
        else:
            name = os.path.splitext(os.path.split(dataFile)[1])[0]
            name += '_xrc.py'
            self.FileNameTC.SetValue(name)
        self.AutoGenerateCB.SetValue(self.cfg.ReadBool("autogenerate", False))
        self.EmbedCB.SetValue(self.cfg.ReadBool("embedResource", False))
        self.MakeXRSFileCB.SetValue(self.cfg.ReadBool("makeXRS", False))
        self.GettextCB.SetValue(self.cfg.ReadBool("genGettext", False)) 
开发者ID:andreas-p,项目名称:admin4,代码行数:33,代码来源:xrced.py

示例8: getResource

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def getResource(self):
    if self.resname.startswith('.'):
      path=os.path.join(adm.loaddir, "%s.xrc" % self.resname)
      self.resname = os.path.basename(self.resname)
    elif self.resname.startswith('/'):
      path="%s.xrc" % self.resname
      self.resname = os.path.basename(self.resname)
    else:
      module=self.module.replace(".", "/")
      path = os.path.join(adm.loaddir, module, "%s.xrc" % self.resname)
    if not os.path.exists(path):
      raise Exception("Loading XRC from %s failed" % path)
    res=xrc.XmlResource(path)
    res.AddHandler(xmlres.XmlResourceHandler())
    return res 
开发者ID:andreas-p,项目名称:admin4,代码行数:17,代码来源:controlcontainer.py

示例9: addControls

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def addControls(self, res):
      from xmlhelp import Document as XmlDocument
      module=self.module.replace(".", "/")
      path = os.path.join(adm.loaddir, module, "%s.xrc" % self.resname)
      doc=XmlDocument.parseFile(path)
      root=doc.getElement('object')
      objects=root.getElements('object')
      for obj in objects:
        name=obj.getAttribute('name')
        if name:
          self._addControl(name, res) 
开发者ID:andreas-p,项目名称:admin4,代码行数:13,代码来源:controlcontainer.py

示例10: test_missing_application_attributes

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def test_missing_application_attributes(self):
        #"Test load wxg file w/ missing <application> attributes and generate code"
        "convert .xrc file with missing <application> attributes to .wxg and load it"
        # this will fail on Python 3.8 as the ordering of elements is not defined
        # convert .xrc to .wxg
        infilename  = self._get_casefile_path('app_wo_attrs_gui.xrc')
        generated_filename = self._get_outputfile_path('app_wo_attrs_gui.wxg')
        xrc2wxg.convert(infilename, generated_filename)
        # compare
        expected_filename = self._get_casefile_path('app_wo_attrs_gui.wxg')
        self._compare_files(expected_filename, generated_filename)
        # open the .wxg file; there should be no problem
        self._messageBox = None
        self.frame._open_app(generated_filename, use_progress_dialog=False, add_to_history=False)
        self.assertFalse(self._messageBox,'Loading test wxg file caused an error message: %s'%self._messageBox) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:17,代码来源:test_gui_new.py

示例11: test_load_xrc

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def test_load_xrc(self):
        "Test loading XRC files"
        res = wx.xrc.EmptyXmlResource()
        for filename in glob.glob(os.path.join(self.caseDirectory, '*.xrc')):
            self.assertTrue( res.Load(filename),
                             'Loading XRC file %s failed' % os.path.relpath(filename, self.caseDirectory) ) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:8,代码来源:test_gui_new.py

示例12: test_import_xrc

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def test_import_xrc(self):
        "Test importing XRC files: just import_test.xrc at the moment"
        infilename = self._get_casefile_path("import_test.xrc")
        common.main.import_xrc(infilename)
        # save file to wxg and check
        generated_filename = self._get_outputfile_path("import_test.wxg")
        compare_filename = self._get_casefile_path("import_test.wxg")
        common.main._save_app(generated_filename)
        self._compare_files(compare_filename, generated_filename) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:11,代码来源:test_gui_new.py

示例13: OnInit

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnInit(self):
        xrcfile = cbook.get_sample_data('embedding_in_wx3.xrc',
                                        asfileobj=False)
        print('loading', xrcfile)

        self.res = xrc.XmlResource(xrcfile)

        # main frame and panel ---------

        self.frame = self.res.LoadFrame(None, "MainFrame")
        self.panel = xrc.XRCCTRL(self.frame, "MainPanel")

        # matplotlib panel -------------

        # container for matplotlib panel (I like to make a container
        # panel for our panel so I know where it'll go when in XRCed.)
        plot_container = xrc.XRCCTRL(self.frame, "plot_container_panel")
        sizer = wx.BoxSizer(wx.VERTICAL)

        # matplotlib panel itself
        self.plotpanel = PlotPanel(plot_container)
        self.plotpanel.init_plot_data()

        # wx boilerplate
        sizer.Add(self.plotpanel, 1, wx.EXPAND)
        plot_container.SetSizer(sizer)

        # whiz button ------------------
        whiz_button = xrc.XRCCTRL(self.frame, "whiz_button")
        whiz_button.Bind(wx.EVT_BUTTON, self.plotpanel.OnWhiz)

        # bang button ------------------
        bang_button = xrc.XRCCTRL(self.frame, "bang_button")
        bang_button.Bind(wx.EVT_BUTTON, self.OnBang)

        # final setup ------------------
        sizer = self.panel.GetSizer()
        self.frame.Show(1)

        self.SetTopWindow(self.frame)

        return True 
开发者ID:holzschu,项目名称:python3_ios,代码行数:44,代码来源:embedding_in_wx3_sgskip.py

示例14: OnSaveOrSaveAs

# 需要导入模块: import wx [as 别名]
# 或者: from wx import xrc [as 别名]
def OnSaveOrSaveAs(self, evt):
        if evt.GetId() == wx.ID_SAVEAS or not self.dataFile:
            if self.dataFile: name = ''
            else: name = defaultName
            dirname = os.path.abspath(os.path.dirname(self.dataFile))
            dlg = wx.FileDialog(self, 'Save As', dirname, name, '*.xrc',
                               wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR)
            if dlg.ShowModal() == wx.ID_OK:
                path = dlg.GetPath()
                if isinstance(path, unicode):
                    path = path.encode(sys.getfilesystemencoding())
                dlg.Destroy()
            else:
                dlg.Destroy()
                return

            if conf.localconf:
                # if we already have a localconf then it needs to be
                # copied to a new config with the new name
                lc = conf.localconf
                nc = self.CreateLocalConf(path)
                flag, key, idx = lc.GetFirstEntry()
                while flag:
                    nc.Write(key, lc.Read(key))
                    flag, key, idx = lc.GetNextEntry(idx)
                conf.localconf = nc
            else:
                # otherwise create a new one
                conf.localconf = self.CreateLocalConf(path)
        else:
            path = self.dataFile
        self.SetStatusText('Saving...')
        wx.BeginBusyCursor()
        try:
            try:
                tmpFile,tmpName = tempfile.mkstemp(prefix='xrced-')
                os.close(tmpFile)
                self.Save(tmpName) # save temporary file first
                shutil.move(tmpName, path)
                self.dataFile = path
                if conf.localconf.ReadBool("autogenerate", False):
                    pypath = conf.localconf.Read("filename")
                    embed = conf.localconf.ReadBool("embedResource", False)
                    genGettext = conf.localconf.ReadBool("genGettext", False)
                    self.GeneratePython(self.dataFile, pypath, embed, genGettext)
                    
                self.SetStatusText('Data saved')
                self.SaveRecent(path)
            except IOError:
                self.SetStatusText('Failed')
        finally:
            wx.EndBusyCursor() 
开发者ID:andreas-p,项目名称:admin4,代码行数:54,代码来源:xrced.py


注:本文中的wx.xrc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。