當前位置: 首頁>>代碼示例>>Python>>正文


Python View.applyname方法代碼示例

本文整理匯總了Python中View.View.applyname方法的典型用法代碼示例。如果您正苦於以下問題:Python View.applyname方法的具體用法?Python View.applyname怎麽用?Python View.applyname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在View.View的用法示例。


在下文中一共展示了View.applyname方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: FormCreator

# 需要導入模塊: from View import View [as 別名]
# 或者: from View.View import applyname [as 別名]

#.........這裏部分代碼省略.........
        mb = wx.MenuBar()
        mb.Append(fmenu, "&File")
        mb.Append(emenu, "&Edit")

        # set menubar to be the main menubar of the frame
        self.SetMenuBar(mb)

        # set the frame to be shown on screen (this is important)
        self.Show(True)

        # Bindings
        self.Bind(wx.EVT_MENU, self.on_open, openbutton)
        self.Bind(wx.EVT_MENU, self.on_save, savebutton)
        self.Bind(wx.EVT_MENU, self.on_close, closebutton)
        self.Bind(wx.EVT_MENU, self.on_print, printbutton)
        self.Bind(wx.EVT_MENU, self.export_print_page, exportbutton)
        self.Bind(wx.EVT_MENU, self.on_about, aboutbutton)
        self.Bind(wx.EVT_MENU, self.on_stats, statsbutton)
        self.Bind(wx.EVT_MENU, self.on_exit, exitbutton)
        self.Bind(wx.EVT_MENU, self.filter, filtbutton)
        self.Bind(wx.EVT_MENU, self.cleanup, cleanbutton)
        self.Bind(wx.EVT_MENU, self.on_delete, deletebutton)
        self.Bind(wx.EVT_MENU, self.del_all, delallbutton)
        self.Bind(wx.EVT_LISTBOX, self.on_selection, self.listbox)
        self.Bind(wx.EVT_BUTTON, self.apply_name, self.applybutton)
        self.Bind(wx.EVT_TEXT, self.typing, self.idtext)

    def typing(self, event):
        """
        Set the text being typed to the rectangle's name
        """
        event.Skip()
        if self.view.image is not None:
            self.view.applyname(self.idtext.Value)

    def on_print(self, event):
        """Print button for debugging"""
        event.Skip()
        if self.view is not None:
            for r in self.view.rects:
                print("{0} : {1} - {2}".format(r.idtag, r.typerect, r.data))

    def on_open(self, event):
        """
        Open up an image and load it to the canvas
        """
        event.Skip()
        dirname = ""
        dlg = wx.FileDialog(self, "Choose a file", dirname, "", "*.*", wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            self.filename = dlg.GetFilename()
            dirname = dlg.GetDirectory()
            self.img = join(dirname, self.filename)
            self.view.image = wx.Bitmap(self.img, type=wx.BITMAP_TYPE_ANY)
            self.view.rects = []
            self.view.Refresh()  # trigger onpaint
            self.SetTitle("Form Creator : " + self.img)

            # Read for an RMAP file
            fname = self.filename.split(".")
            fname.pop()
            rmap_file = join(dirname, ".".join(fname + ["rmap"]))

            if isfile(rmap_file):
                # the file is here!
                with open(rmap_file, "r") as f:
開發者ID:sleibrock,項目名稱:form-creator,代碼行數:70,代碼來源:FormCreator.py


注:本文中的View.View.applyname方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。