Python wx.ID_CLOSE Examples

The following are 16 code examples of wx.ID_CLOSE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: objdictedit.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def RefreshMainMenu(self):
        if self.FileOpened.GetPageCount() > 0:
            if self.ModeSolo:
                self.MenuBar.EnableTop(1, True)
                self.MenuBar.EnableTop(2, True)
                self.FileMenu.Enable(wx.ID_CLOSE, True)
                self.FileMenu.Enable(wx.ID_SAVE, True)
                self.FileMenu.Enable(wx.ID_SAVEAS, True)
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTEDS, True)
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTC, True)
            else:
                self.MenuBar.EnableTop(0, True)
                self.MenuBar.EnableTop(1, True)
        else:
            if self.ModeSolo:
                self.MenuBar.EnableTop(1, False)
                self.MenuBar.EnableTop(2, False)
                self.FileMenu.Enable(wx.ID_CLOSE, False)
                self.FileMenu.Enable(wx.ID_SAVE, False)
                self.FileMenu.Enable(wx.ID_SAVEAS, False)
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTEDS, False)
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTC, False)
            else:
                self.MenuBar.EnableTop(0, False)
                self.MenuBar.EnableTop(1, False) 
Example #2
Source File: networkedit.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def _init_coll_FileMenu_Items(self, parent):
        parent.Append(help='', id=wx.ID_NEW,
              kind=wx.ITEM_NORMAL, text=_('New\tCTRL+N'))
        parent.Append(help='', id=wx.ID_OPEN,
              kind=wx.ITEM_NORMAL, text=_('Open\tCTRL+O'))
        parent.Append(help='', id=wx.ID_CLOSE,
              kind=wx.ITEM_NORMAL, text=_('Close\tCTRL+W'))
        parent.AppendSeparator()
        parent.Append(help='', id=wx.ID_SAVE,
              kind=wx.ITEM_NORMAL, text=_('Save\tCTRL+S'))
        parent.AppendSeparator()
        parent.Append(help='', id=wx.ID_EXIT,
              kind=wx.ITEM_NORMAL, text=_('Exit'))
        self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
        self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE)
        self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) 
Example #3
Source File: AboutDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, info):
        wx.Dialog.__init__(self, parent, title=_("License"), size=(500, 400),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        if parent and parent.GetIcon():
            self.SetIcon(parent.GetIcon())

        self.SetMinSize((400, 300))
        close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close"))

        ctrl = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE)
        ctrl.SetValue(info.License)

        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(close)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(ctrl, 1, wx.EXPAND | wx.ALL, 10)
        sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10)
        self.SetSizer(sizer)
        self.Layout()
        self.Show()
        self.SetEscapeId(close.GetId())

        close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) 
Example #4
Source File: live_demo.py    From mr_saliency with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self,parent):
        wx.Panel.__init__(self,parent)
        #self.save = wx.Button(self,label="Save")
        #self.close = wx.Button(self,label="Close")
        self.close = wx.Button(self,wx.ID_CLOSE)
        self.close.Bind(wx.EVT_BUTTON, self.OnClose)


        self.sizer = wx.GridBagSizer(1,2)
        self.sizer.Add(self.close,(1,1))
        #self.sizer.Add(self.close,(1,2,)) 
Example #5
Source File: objdictedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def _init_coll_FileMenu_Items(self, parent):
        parent.Append(help='', id=wx.ID_NEW,
              kind=wx.ITEM_NORMAL, text=_('New\tCTRL+N'))
        parent.Append(help='', id=wx.ID_OPEN,
              kind=wx.ITEM_NORMAL, text=_('Open\tCTRL+O'))
        parent.Append(help='', id=wx.ID_CLOSE,
              kind=wx.ITEM_NORMAL, text=_('Close\tCTRL+W'))
        parent.AppendSeparator()
        parent.Append(help='', id=wx.ID_SAVE,
              kind=wx.ITEM_NORMAL, text=_('Save\tCTRL+S'))
        parent.Append(help='', id=wx.ID_SAVEAS,
              kind=wx.ITEM_NORMAL, text=_('Save As...\tALT+S'))
        parent.AppendSeparator()
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUIMPORTEDS,
              kind=wx.ITEM_NORMAL, text=_('Import EDS file'))
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUEXPORTEDS,
              kind=wx.ITEM_NORMAL, text=_('Export to EDS file'))
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUEXPORTC,
              kind=wx.ITEM_NORMAL, text=_('Build Dictionary\tCTRL+B'))
        parent.AppendSeparator()
        parent.Append(help='', id=wx.ID_EXIT,
              kind=wx.ITEM_NORMAL, text=_('Exit'))
        self.Bind(wx.EVT_MENU, self.OnNewMenu, id=wx.ID_NEW)
        self.Bind(wx.EVT_MENU, self.OnOpenMenu, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self.OnCloseMenu, id=wx.ID_CLOSE)
        self.Bind(wx.EVT_MENU, self.OnSaveMenu, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self.OnSaveAsMenu, id=wx.ID_SAVEAS)
        self.Bind(wx.EVT_MENU, self.OnImportEDSMenu,
              id=ID_OBJDICTEDITFILEMENUIMPORTEDS)
        self.Bind(wx.EVT_MENU, self.OnExportEDSMenu,
              id=ID_OBJDICTEDITFILEMENUEXPORTEDS)
        self.Bind(wx.EVT_MENU, self.OnExportCMenu,
              id=ID_OBJDICTEDITFILEMENUEXPORTC)
        self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) 
Example #6
Source File: networkedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def RefreshMainMenu(self):
        self.NetworkMenu.Enable(ID_NETWORKEDITNETWORKMENUBUILDMASTER, False)
        if self.NodeList == None:
            if self.ModeSolo:
                self.MenuBar.EnableTop(1, False)
                self.MenuBar.EnableTop(2, False)
                self.MenuBar.EnableTop(3, False)
                if self.FileMenu:
                    self.FileMenu.Enable(wx.ID_CLOSE, False)
                    self.FileMenu.Enable(wx.ID_SAVE, False)
            else:
                self.MenuBar.EnableTop(0, False)
                self.MenuBar.EnableTop(1, False)
                self.MenuBar.EnableTop(2, False)
        else:
            if self.ModeSolo:
                self.MenuBar.EnableTop(1, True)
                if self.FileMenu:
                    self.FileMenu.Enable(wx.ID_CLOSE, True)
                    self.FileMenu.Enable(wx.ID_SAVE, True)
                if self.NetworkNodes.GetSelection() == 0:
                    self.MenuBar.EnableTop(2, True)
                    self.MenuBar.EnableTop(3, True)
                else:
                    self.MenuBar.EnableTop(2, False)      
                    self.MenuBar.EnableTop(3, False)
            else:
                self.MenuBar.EnableTop(0, True)
                if self.NetworkNodes.GetSelection() == 0:
                    self.MenuBar.EnableTop(1, True)
                    self.MenuBar.EnableTop(2, True)
                else:
                    self.MenuBar.EnableTop(1, False)      
                    self.MenuBar.EnableTop(2, False)

#-------------------------------------------------------------------------------
#                              Buffer Functions
#------------------------------------------------------------------------------- 
Example #7
Source File: ComplexExample.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrameGrid.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((492, 300))
        self.SetTitle(_("FrameOggCompressionDetails"))

        self._szr_frame = wx.BoxSizer(wx.VERTICAL)

        self.grid_sizer = wx.FlexGridSizer(3, 1, 0, 0)
        self._szr_frame.Add(self.grid_sizer, 1, wx.EXPAND, 0)

        self.grid = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1))
        self.grid.CreateGrid(8, 3)
        self.grid_sizer.Add(self.grid, 1, wx.EXPAND, 0)

        self.static_line = wx.StaticLine(self, wx.ID_ANY)
        self.grid_sizer.Add(self.static_line, 0, wx.ALL | wx.EXPAND, 5)

        self.button = wx.Button(self, wx.ID_CLOSE, "")
        self.button.SetFocus()
        self.button.SetDefault()
        self.grid_sizer.Add(self.button, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.grid_sizer.AddGrowableRow(0)
        self.grid_sizer.AddGrowableCol(0)

        self.SetSizer(self._szr_frame)
        self._szr_frame.SetSizeHints(self)

        self.Layout()
        # end wxGlade

# end of class MyFrameGrid 
Example #8
Source File: ComplexExample_30_Classic.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrameGrid.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((492, 300))
        self.SetTitle(_("FrameOggCompressionDetails"))

        self._szr_frame = wx.BoxSizer(wx.VERTICAL)

        self.grid_sizer = wx.FlexGridSizer(3, 1, 0, 0)
        self._szr_frame.Add(self.grid_sizer, 1, wx.EXPAND, 0)

        self.grid = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1))
        self.grid.CreateGrid(8, 3)
        self.grid_sizer.Add(self.grid, 1, wx.EXPAND, 0)

        self.static_line = wx.StaticLine(self, wx.ID_ANY)
        self.grid_sizer.Add(self.static_line, 0, wx.ALL | wx.EXPAND, 5)

        self.button = wx.Button(self, wx.ID_CLOSE, "")
        self.button.SetFocus()
        self.button.SetDefault()
        self.grid_sizer.Add(self.button, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.grid_sizer.AddGrowableRow(0)
        self.grid_sizer.AddGrowableCol(0)

        self.SetSizer(self._szr_frame)
        self._szr_frame.SetSizeHints(self)

        self.Layout()
        # end wxGlade

# end of class MyFrameGrid 
Example #9
Source File: ComplexExample_30_Phoenix.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrameGrid.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((492, 300))
        self.SetTitle(_("FrameOggCompressionDetails"))

        self._szr_frame = wx.BoxSizer(wx.VERTICAL)

        self.grid_sizer = wx.FlexGridSizer(3, 1, 0, 0)
        self._szr_frame.Add(self.grid_sizer, 1, wx.EXPAND, 0)

        self.grid = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1))
        self.grid.CreateGrid(8, 3)
        self.grid_sizer.Add(self.grid, 1, wx.EXPAND, 0)

        self.static_line = wx.StaticLine(self, wx.ID_ANY)
        self.grid_sizer.Add(self.static_line, 0, wx.ALL | wx.EXPAND, 5)

        self.button = wx.Button(self, wx.ID_CLOSE, "")
        self.button.SetFocus()
        self.button.SetDefault()
        self.grid_sizer.Add(self.button, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.grid_sizer.AddGrowableRow(0)
        self.grid_sizer.AddGrowableCol(0)

        self.SetSizer(self._szr_frame)
        self._szr_frame.SetSizeHints(self)

        self.Layout()
        # end wxGlade

# end of class MyFrameGrid 
Example #10
Source File: PyOgg3.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: PyOgg3_MyDialog.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
        wx.Dialog.__init__(self, *args, **kwds)
        self.notebook_1 = wx.Notebook(self, wx.ID_ANY)
        self.notebook_1_pane_1 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_pane_1, wx.ID_ANY, "")
        self.button_3 = wx.Button(self.notebook_1_pane_1, wx.ID_OPEN, "")
        self.notebook_1_pane_2 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.radio_box_1 = wx.RadioBox(self.notebook_1_pane_2, wx.ID_ANY, _("Sampling Rate"), choices=[_("44 kbit"), _("128 kbit")], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.notebook_1_pane_3 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_pane_3, wx.ID_ANY, "", style=wx.TE_MULTILINE)
        self.notebook_1_pane_4 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.label_2 = wx.StaticText(self.notebook_1_pane_4, wx.ID_ANY, _("File name:"))
        self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_pane_4, wx.ID_ANY, "")
        self.button_4 = wx.Button(self.notebook_1_pane_4, wx.ID_OPEN, "")
        self.checkbox_1 = wx.CheckBox(self.notebook_1_pane_4, wx.ID_ANY, _("Overwrite existing file"))
        self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
        self.button_5 = wx.Button(self, wx.ID_CLOSE, "")
        self.button_2 = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_TOP)
        self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.startConverting, self.button_1)
        # end wxGlade

        # manually added code
        print( 'Dialog has been created at ', time.asctime() ) 
Example #11
Source File: PyOgg3.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: PyOgg3_MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.grid_1 = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1))
        self.static_line_2 = wx.StaticLine(self, wx.ID_ANY)
        self.button_6 = wx.Button(self, wx.ID_CLOSE, "")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

        # manually added code
        print( 'Frame has been created at ', datetime.datetime.now().isoformat() ) 
Example #12
Source File: PyOgg2_MyFrame.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: PyOgg2_MyFrame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((400, 300))
        self.SetTitle(_("FrameOggCompressionDetails"))

        sizer_5 = wx.BoxSizer(wx.VERTICAL)

        grid_sizer_3 = wx.FlexGridSizer(3, 1, 0, 0)
        sizer_5.Add(grid_sizer_3, 1, wx.EXPAND, 0)

        self.grid_1 = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1))
        self.grid_1.CreateGrid(8, 3)
        grid_sizer_3.Add(self.grid_1, 1, wx.EXPAND, 0)

        self.static_line_2 = wx.StaticLine(self, wx.ID_ANY)
        grid_sizer_3.Add(self.static_line_2, 0, wx.ALL | wx.EXPAND, 5)

        self.button_6 = wx.Button(self, wx.ID_CLOSE, "")
        self.button_6.SetFocus()
        self.button_6.SetDefault()
        grid_sizer_3.Add(self.button_6, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        grid_sizer_3.AddGrowableRow(0)
        grid_sizer_3.AddGrowableCol(0)

        self.SetSizer(sizer_5)

        self.Layout()
        # end wxGlade 
Example #13
Source File: AboutDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, info):
        wx.Dialog.__init__(self, parent, title=_("Credits"), size=(475, 320),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        if parent and parent.GetIcon():
            self.SetIcon(parent.GetIcon())

        self.SetMinSize((300, 200))
        notebook = wx.Notebook(self)
        close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close"))
        close.SetDefault()

        developer = wx.TextCtrl(notebook, style=wx.TE_READONLY | wx.TE_MULTILINE)
        translators = wx.TextCtrl(notebook, style=wx.TE_READONLY | wx.TE_MULTILINE)

        developer.SetValue(u'\n'.join(info.Developers))
        translators.SetValue(u'\n'.join(info.Translators))

        notebook.AddPage(developer, text=_("Written by"))
        notebook.AddPage(translators, text=_("Translated by"))

        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(close)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 10)
        sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10)
        self.SetSizer(sizer)
        self.Layout()
        self.Show()
        self.SetEscapeId(close.GetId())

        close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) 
Example #14
Source File: autosetup_tty.py    From openplotter with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self):
		self.serial = 0

		self.conf = Conf()
		Language(self.conf)
		wx.Frame.__init__(self, None, wx.ID_ANY, _('tty auto setup'), size=(720, 350))

		# Add a panel so it looks the correct on all platforms
		panel = wx.Panel(self, wx.ID_ANY)
		log = wx.TextCtrl(panel, wx.ID_ANY, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)

		self.autostart = wx.CheckBox(panel, label=_('setup autostart on every boot'))
		self.autostart.Bind(wx.EVT_CHECKBOX, self.on_autostart)

		setup = wx.Button(panel, wx.ID_ANY, 'setup')
		setup.Bind(wx.EVT_BUTTON, on_setup)
		close = wx.Button(panel, wx.ID_CLOSE)
		close.Bind(wx.EVT_BUTTON, self.on_close)

		# Add widgets to a sizer		
		hbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox.Add(self.autostart, 0, wx.ALL | wx.EXPAND, 5)
		hbox.Add((0, 0), 1, wx.ALL | wx.EXPAND, 5)
		hbox.Add(setup, 0, wx.ALL | wx.EXPAND, 5)
		hbox.Add(close, 0, wx.ALL | wx.EXPAND, 5)

		vbox = wx.BoxSizer(wx.VERTICAL)
		vbox.Add(log, 1, wx.ALL | wx.EXPAND, 5)
		vbox.Add(hbox, 0, wx.ALL | wx.CENTER | wx.EXPAND, 5)
		panel.SetSizer(vbox)

		self.tool_list = []
		data = self.conf.get('TOOLS', 'py')
		try:
			temp_list = eval(data)
		except:
			temp_list = []
		for ii in temp_list:
			self.tool_list.append(ii)
		self.tool = []
		self.tool_exist = False
		for i in self.tool_list:
			if i[2] == 'autosetup_tty.py':
				self.autostart.SetValue(i[3] == '1')
				self.tool.append(i)
				self.tool_exist = True

		# redirect text here
		redir = RedirectText(log)
		sys.stdout = redir

		print _('Auto setup detects hardware. Please make sure that all devices are turned on.')
		print 
Example #15
Source File: PLCOpenEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def _init_coll_FileMenu_Items(self, parent):
        AppendMenu(parent, help='', id=wx.ID_NEW,
                   kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N')
        AppendMenu(parent, help='', id=wx.ID_OPEN,
                   kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O')
        AppendMenu(parent, help='', id=wx.ID_CLOSE,
                   kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W')
        AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL,
                   kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W')
        parent.AppendSeparator()
        AppendMenu(parent, help='', id=wx.ID_SAVE,
                   kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S')
        AppendMenu(parent, help='', id=wx.ID_SAVEAS,
                   kind=wx.ITEM_NORMAL, text=_(u'Save As...') + '\tCTRL+SHIFT+S')
        AppendMenu(parent, help='', id=ID_PLCOPENEDITORFILEMENUGENERATE,
                   kind=wx.ITEM_NORMAL, text=_(u'Generate Program') + '\tCTRL+G')
        AppendMenu(parent, help='', id=ID_PLCOPENEDITORFILEMENUGENERATEAS,
                   kind=wx.ITEM_NORMAL, text=_(u'Generate Program As...') + '\tCTRL+SHIFT+G')
        parent.AppendSeparator()
        AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP,
                   kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P')
        AppendMenu(parent, help='', id=wx.ID_PREVIEW,
                   kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P')
        AppendMenu(parent, help='', id=wx.ID_PRINT,
                   kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P')
        parent.AppendSeparator()
        AppendMenu(parent, help='', id=wx.ID_PROPERTIES,
                   kind=wx.ITEM_NORMAL, text=_(u'&Properties'))
        parent.AppendSeparator()
        AppendMenu(parent, help='', id=wx.ID_EXIT,
                   kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q')

        self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
        self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE)
        self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL)
        self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS)
        self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu,
                  id=ID_PLCOPENEDITORFILEMENUGENERATE)
        self.Bind(wx.EVT_MENU, self.OnGenerateProgramAsMenu,
                  id=ID_PLCOPENEDITORFILEMENUGENERATEAS)
        self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP)
        self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW)
        self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT)
        self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
        self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)

        self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None),
                               (wx.ID_OPEN, "open", _(u'Open'), None),
                               (wx.ID_SAVE, "save", _(u'Save'), None),
                               (wx.ID_SAVEAS, "saveas", _(u'Save As...'), None),
                               (wx.ID_PRINT, "print", _(u'Print'), None),
                               (ID_PLCOPENEDITORFILEMENUGENERATE, "Build", _(u'Generate Program'), None)]) 
Example #16
Source File: PLCOpenEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def RefreshFileMenu(self):
        MenuToolBar = self.Panes["MenuToolBar"]
        if self.Controler is not None:
            selected = self.TabsOpened.GetSelection()
            if selected >= 0:
                graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer)
            else:
                graphic_viewer = False
            if self.TabsOpened.GetPageCount() > 0:
                self.FileMenu.Enable(wx.ID_CLOSE, True)
                if graphic_viewer:
                    self.FileMenu.Enable(wx.ID_PREVIEW, True)
                    self.FileMenu.Enable(wx.ID_PRINT, True)
                    MenuToolBar.EnableTool(wx.ID_PRINT, True)
                else:
                    self.FileMenu.Enable(wx.ID_PREVIEW, False)
                    self.FileMenu.Enable(wx.ID_PRINT, False)
                    MenuToolBar.EnableTool(wx.ID_PRINT, False)
            else:
                self.FileMenu.Enable(wx.ID_CLOSE, False)
                self.FileMenu.Enable(wx.ID_PREVIEW, False)
                self.FileMenu.Enable(wx.ID_PRINT, False)
                MenuToolBar.EnableTool(wx.ID_PRINT, False)
            self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
            project_modified = not self.Controler.ProjectIsSaved()
            self.FileMenu.Enable(wx.ID_SAVE, project_modified)
            MenuToolBar.EnableTool(wx.ID_SAVE, project_modified)
            self.FileMenu.Enable(wx.ID_PROPERTIES, True)
            self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
            self.FileMenu.Enable(wx.ID_SAVEAS, True)
            MenuToolBar.EnableTool(wx.ID_SAVEAS, True)
            self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True)
            MenuToolBar.EnableTool(ID_PLCOPENEDITORFILEMENUGENERATE, True)
            self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATEAS, True)
        else:
            self.FileMenu.Enable(wx.ID_CLOSE, False)
            self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
            self.FileMenu.Enable(wx.ID_PREVIEW, False)
            self.FileMenu.Enable(wx.ID_PRINT, False)
            MenuToolBar.EnableTool(wx.ID_PRINT, False)
            self.FileMenu.Enable(wx.ID_SAVE, False)
            MenuToolBar.EnableTool(wx.ID_SAVE, False)
            self.FileMenu.Enable(wx.ID_PROPERTIES, False)
            self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
            self.FileMenu.Enable(wx.ID_SAVEAS, False)
            MenuToolBar.EnableTool(wx.ID_SAVEAS, False)
            self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False)
            MenuToolBar.EnableTool(ID_PLCOPENEDITORFILEMENUGENERATE, False)
            self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATEAS, False)