def on_open(self, event): self.camera = devices[self.com_devices.GetValue()]() if not self.camera.view is None: dialog = ParaDialog(self, self.camera.name) view, para = self.camera.view, self.camera.para.copy() dialog.init_view(view, para, False) if dialog.show(): self.camera.para.update(para) self.camera.open() else: self.camera.open()
def show_para(self, title, view, para, on_handle=None, on_ok=None, on_cancel=None, preview=False, modal=True): dialog = ParaDialog(self, title) dialog.init_view(view, para, preview, modal=modal, app=self) dialog.Bind('cancel', on_cancel) dialog.Bind('parameter', on_handle) dialog.Bind('commit', on_ok) return dialog.show()
def mouse_up(self, ips, x, y, btn, **key): if len(self.pos) == 2: print("pos = ", self.pos) para = {'scalebar': 200} view = [('lab', 'lab', 'Please input the real length the scale bar'), (int, 'scalebar', (0, 1000), 1, 'Length', 'um')] pd = ParaDialog(None, 'Scale bar') pd.init_view(view, para, preview=False, modal=True) pd.ShowModal() ConfigManager.set( 'scalebar', para['scalebar'] / (self.pos[1][1] - self.pos[0][1])) print(ConfigManager.get('scalebar'))
def mouse_up(self, ips, x, y, btn, **key): if len(self.pos) == 2: print("pos = ", self.pos) para = {'scalebar': 200} view = [('lab', 'lab', 'Please input the real length the scale bar'), (int, 'scalebar', (0, 1000), 1, 'Length', 'um')] pd = ParaDialog(None, 'Scale bar') pd.init_view(view, para, preview=False, modal=True) pd.ShowModal() ConfigManager.set('scalebar', para['scalebar']/(self.pos[1][1]-self.pos[0][1])) print("scale bar = ", ConfigManager.get('scalebar')) pt_left, pt_right, pt_up, pt_down, ips.img = ExtractUpperBoundary(ips.img) key['canvas'].marks = make_mark(pt_left, pt_right, pt_up, pt_down, ips.img)['body'] ips.update() self.pos = []
def show_para(self, title, para, view, on_handle=None, on_ok=None, on_cancel=None, on_help=None, preview=False, modal=True): on_help = lambda x=None:self.show_md(x or 'No Document!', title) dialog = ParaDialog(self, title) dialog.init_view(view, para, preview, modal=modal, app=self) dialog.Bind('cancel', on_cancel) dialog.Bind('parameter', on_handle) dialog.Bind('commit', on_ok) dialog.Bind('help', on_help) return dialog.show()
def show_para(self, title, para, view, on_handle=None, on_ok=None, on_cancel=None, on_help=None, preview=False, modal=True): lang = ConfigManager.get('language') dic = DictManager.get(name=title, tag=lang) doc = DocumentManager.get(title, tag=lang) doc = doc or DocumentManager.get(title, tag='English') on_help = lambda x=doc:self.show_md(x or 'No Document!', title) dialog = ParaDialog(self, title) dialog.init_view(view, para, preview, modal=modal, app=self) self.translate(dic)(dialog) dialog.Bind('cancel', on_cancel) dialog.Bind('parameter', on_handle) dialog.Bind('commit', on_ok) dialog.Bind('help', on_help) return dialog.show()
def show_para(self, title, view, para, on_handle=None, on_ok=None, on_cancel=None, on_help=None, preview=False, modal=True): lang = Source.manager('config').get('language') dic = Source.manager('dictionary').get(name=title, tag=lang) dialog = ParaDialog(self, title, dic or {}) dialog.init_view(view, para, preview, modal=modal, app=self) dialog.Bind('cancel', on_cancel) dialog.Bind('parameter', on_handle) dialog.Bind('commit', on_ok) dialog.Bind('help', on_help) return dialog.show()
def on_config(self, event): dialog = ParaDialog(self, self.camera.name) view, para = self.camera.view, self.camera.para.copy() dialog.init_view(view, para, False) if dialog.show(): self.camera.para.update(para)
'h': 1.72, 'w': 70, 'sport': True, 'sys': 'Mac', 'lan': ['C/C++', 'Python'], 'c': (255, 255, 0), 'path': '', 'type': None } view = [('lab', 'lab', 'This is a questionnaire'), (str, 'name', 'name', 'please'), (int, 'age', (0, 150), 1, 'age', 'years old'), (float, 'h', (0.3, 2.5), 2, 'height', 'm'), ('slide', 'w', (1, 150), 0, 'weight', 'kg'), (bool, 'sport', 'do you like sport'), (list, 'sys', ['Windows', 'Mac', 'Linux'], str, 'favourite', 'system'), ('chos', 'lan', ['C/C++', 'Java', 'Python'], 'lanuage you like(multi)'), ('color', 'c', 'which', 'you like'), ('path', 'path', 'Select the image', ['jpg', 'jpeg', 'png'])] app = wx.App() pd = ParaDialog(None, 'Test') pd.init_view(view, para, preview=True, modal=True) pd.pack() pd.ShowModal() print(para) app.MainLoop()