Exemplo n.º 1
0
    def OnButtonClick(self, propGrid, value):
        # Create dialog dlg at dlgPos. Use value as initial string value.
        # with CalibreSearch.SearchDialog(None, pos=dlgPos) as dlg:
        with CalibreSearch.SearchDialog(None) as dlg:
            if dlg.ShowModal() == wx.ID_ADD:
                return True, dlg.GetSelection()

            return False, value
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title="Calibre Search",
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 name=wx.DialogNameStr):
        """
		:param parent: Can be None, a frame or another dialog box.
		:type parent: wx.Window
		:param id: An identifier for the dialog. A value of -1 is taken to mean a default.
		:type id: wx.WindowID
		:param title: The title of the dialog.
		:type title: str
		:param pos: The dialog position. The value DefaultPosition indicates a
		default position, chosen by either the windowing system or wxWidgets,
		depending on platform.
		:type pos: wx.Point
		:param style: The window style.
		:type style: int
		:param name: Used to associate a name with the window, allowing the
		application user to set Motif resource values for individual dialog boxes.
		:type name: str
		"""

        args = (parent, id, title, pos)
        kwds = {
            "style": style,
            "name": name,
        }

        kwds["style"] = kwds.get("style",
                                 0) | wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX
        wx.Dialog.__init__(self, *args, **kwds)
        self.info_panel = CalibreSearch.InfoPanel(self, wx.ID_ANY)
        self.info_panel.SetEditable(True)

        self.btns = self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL)
        self.FindWindowById(self.GetAffirmativeId()).SetLabel("&Add")

        self.type_selection = wx.ComboBox(
            self,
            choices=[
                "Rifles", "Handguns", "Military Rifles", "Rimfire Cartridges",
                "Shotgun Shells", "Blanks / Starting Gun Cartridges"
            ])

        self._do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_cancel, id=wx.ID_CANCEL)
        self.Bind(wx.EVT_BUTTON, self.on_add, id=wx.ID_OK)
Exemplo n.º 3
0
		def OnInit(self):
			# For debugging
			# self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG|wx.PYAPP_ASSERT_EXCEPTION)
			
			wx.SystemOptions.SetOption("mac.window-plain-transition", 1)
			self.SetAppName("Calibre Search")
			
			dialog = CalibreSearch.SearchDialog(None)
			if dialog.ShowModal() == wx.ID_ADD:
				print(dialog.GetSelection())
				print("^^^^^")
			
			frame = CalibreSearchFrame(None, title="Calibre Search Frame")
			frame.Show()
			
			return True
Exemplo n.º 4
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title="Calibre Search",
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 name=wx.DialogNameStr):
        """
		:param parent: Can be None, a frame or another dialog box.
		:type parent: wx.Window
		:param id: An identifier for the dialog. A value of -1 is taken to mean a default.
		:type id: wx.WindowID
		:param title: The title of the dialog.
		:type title: str
		:param pos: The dialog position. The value DefaultPosition indicates a
		default position, chosen by either the windowing system or wxWidgets,
		depending on platform.
		:type pos: wx.Point
		:param style: The window style.
		:type style: int
		:param name: Used to associate a name with the window, allowing the
		application user to set Motif resource values for individual dialog boxes.
		:type name: str
		"""

        args = (parent, id, title, pos)
        kwds = {
            "style": style,
            "name": name,
        }

        # begin wxGlade: CalibreSearchDialog.__init__
        kwds["style"] = kwds.get("style",
                                 0) | wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX
        wx.Dialog.__init__(self, *args, **kwds)
        self.CalibreSearchPanel = CalibreSearch.SearchPanel(self,
                                                            wx.ID_ANY,
                                                            dialog=True)

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

        self.Bind(wx.EVT_BUTTON, self.on_cancel, id=wx.ID_CANCEL)
        self.Bind(wx.EVT_BUTTON, self.on_select, id=wx.ID_ADD)
Exemplo n.º 5
0
	def __init__(
			self, parent, id=wx.ID_ANY, title="Calibre Search", pos=wx.DefaultPosition,
			style=wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN | wx.NO_FULL_REPAINT_ON_RESIZE,
			name=wx.FrameNameStr
			):
		"""
		:param parent: The window parent. This may be, and often is, None. If it is not None, the frame will be minimized when its parent is minimized and restored when it is restored (although it will still be possible to minimize
		:type parent: wx.Window
		:param id: The window identifier. It may take a value of -1 to indicate a default value.
		:type id: wx.WindowID, optional
		:param title: The caption to be displayed on the frame’s title bar.
		:type title: str, optional
		:param pos: The window position. The value DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.
		:type pos: wx.Point, optional
		:param style: The window style. See wx.Frame class description.
		:type style: int, optional
		:param name: The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.
		:type name: str, optional
		"""
		
		wx.Frame.__init__(self, parent, id=id, title=title, pos=pos, style=style, name=name)
		
		self.CalibreSearchPanel = CalibreSearch.SearchPanel(self)
		
		self.SetSize(self.CalibreSearchPanel.GetSize())
		self.SetMinSize(self.CalibreSearchPanel.GetSize())

		grid_sizer = wx.GridSizer(1, 1, 0, 0)
		grid_sizer.Add(self.CalibreSearchPanel, 1, wx.EXPAND, 0)
		self.SetSizer(grid_sizer)
		self.Layout()
		
		self.Bind(wx.EVT_CLOSE, self.on_close_window)
		self.Bind(wx.EVT_ICONIZE, self.on_iconfiy)
		self.Bind(wx.EVT_MAXIMIZE, self.on_maximize)
		
		# self.CalibreSearchPanel.buttons.show_select_cancel_grid(False)
		# cur_min_size = self.GetMinSize()
		#
		# self.SetMinSize((cur_min_size.x, cur_min_size.y-34))
		# self.SetSize((size.x, size.y-34))
		
		# self.Centre(wx.BOTH)
		
		wx.GetApp().Bind(wx.EVT_ACTIVATE_APP, self.on_app_activate)
	def __init__(
			self, parent, id=wx.ID_ANY,
			pos=wx.DefaultPosition,
			style=0, name="CalibreSearchPanel", dialog=False
			):
		"""
		:param parent: The parent window.
		:type parent: wx.Window
		:param id: An identifier for the panel. wx.ID_ANY is taken to mean a default.
		:type id: wx.WindowID, optional
		:param pos: The panel position. The value wx.DefaultPosition indicates a default position,
		chosen by either the windowing system or wxWidgets, depending on platform.
		:type pos: wx.Point, optional
		:param style: The window style. See wx.Panel.
		:type style: int, optional
		:param name: Window name.
		:type name: str, optional
		:param dialog:
		:type dialog:
		"""
		
		self.parent = parent
		
		wx.Panel.__init__(
				self, parent, id=id, pos=pos,
				style=style | wx.TAB_TRAVERSAL, name=name
				)
		
		# Left panel with TreeCtrl and SearchCtrl
		self.leftPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN)

		self.treeMap = {}
		self.searchItems = {}
		self.tree = CalibreTree(self.leftPanel)
		self.root = self.tree.AddRoot("")

		self.filter = wx.SearchCtrl(self.leftPanel, style=wx.TE_PROCESS_ENTER)
		searchMenu = wx.Menu()
		item = searchMenu.AppendRadioItem(-1, "Calibre Name")
		self.Bind(wx.EVT_MENU, self.on_search_menu, item)
		item = searchMenu.AppendRadioItem(-1, "Calibre Properties")
		self.Bind(wx.EVT_MENU, self.on_search_menu, item)
		self.filter.SetMenu(searchMenu)
		self._filter_menu_opts = searchMenu.GetMenuItems()
		
		# Right panel with CalibreInfoPanel and New Calibre button
		self.rightPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN)
		self.info_panel = CalibreSearch.InfoPanel(self.rightPanel, wx.ID_ANY, style=wx.CLIP_CHILDREN)
		
		if dialog:
			size = (650, 620)
			self.buttons = CalibreSearch.ButtonPanel(self.rightPanel)
		else:
			size = (660, 575)
			self.buttons = CalibreSearch.NewCalibreButtonPanel(self.rightPanel)
		
		self.SetSize(size)
		self.SetMinSize(size)
		self.SetMaxSize(size)
		
		self.filter.ShowCancelButton(True)
		self.info_panel.SetEditable(False)
		
		self._do_layout()
		self._bind_events()
		self._compile_calibre_list()
		
		self.tree.ExpandAll()
		self.recreate_tree()
	def on_new_calibre(self, _):
		with CalibreSearch.NewCalibreDialog(self) as dlg:
			print(dlg.ShowModal())
			print(dlg.GetData().__dict__)