def __init__(self, parent, title='', timeout=0, resizable=0, width=-1, height=-1, text='', justify='center', strings=("OK",), default=0, separator=False, padx=20, pady=20, bitmap=None, bitmap_side='left', bitmap_padx=20, bitmap_pady=20, image=None, image_side='left', image_padx=10, image_pady=20, **kw): _MyDialog.__init__(self) self.status = 1 self.button = -1 self.buttons = [] modal = True if modal: setTransient(self, parent) # settings if width > 0 or height > 0: self.set_size_request(width, height) # self.window.resize(width, height) self.set_title(title) # self.connect('key-press-event', self._keyPressEvent)
def init(self, parent, message="", modal=True): if modal: setTransient(self, parent) box = gtk.VBox(spacing=10) box.set_border_width(10) self.vbox.pack_start(box) box.show() if message: label = gtk.Label(message) box.pack_start(label) label.show() self.entry = gtk.Entry() box.pack_start(self.entry) self.entry.show() self.entry.grab_focus() button = gtk.Button("OK") button.connect("clicked", self.done) button.set_flags(gtk.CAN_DEFAULT) self.action_area.pack_start(button) button.show() button.grab_default() button = gtk.Button("Cancel") button.connect("clicked", self.quit) button.set_flags(gtk.CAN_DEFAULT) self.action_area.pack_start(button) button.show()
def __init__(self, app, parent, title=None, images=None, color="blue", width=300, height=25, show_text=1, norm=1): self.parent = parent self.percent = 0 self.top = makeToplevel(parent, title=title) self.top.wm_protocol("WM_DELETE_WINDOW", self.wmDeleteWindow) self.top.wm_group(parent) self.top.wm_resizable(False, False) self.top.config(cursor="watch") # self.frame = ttk.Frame(self.top, relief='flat', borderwidth=0) self.progress = ttk.Progressbar(self.frame, maximum=100, length=250) ##style = ttk.Style(self.progress) ##style.configure('TProgressbar', background=color) if images: self.f1 = ttk.Label(self.frame, image=images[0]) self.f1.pack(side='left', ipadx=8, ipady=4) self.progress.pack(side='left', expand=True, fill='x') self.f2 = ttk.Label(self.frame, image=images[1]) self.f2.pack(side='left', ipadx=8, ipady=4) else: self.progress.pack(expand=True, fill='x') self.frame.pack(expand=True, fill='both') if 1: setTransient(self.top, None, relx=0.5, rely=0.5) else: self.update(percent=0) self.norm = norm self.steps_sum = 0
def __init__(self, parent, title='', timeout=0, resizable=0, width=-1, height=-1, text='', justify='center', strings=("OK",), default=0, separator=False, padx=20, pady=20, bitmap=None, bitmap_side='left', bitmap_padx=20, bitmap_pady=20, image=None, image_side='left', image_padx=10, image_pady=20, **kw): _MyDialog.__init__(self) self.status = 1 self.button = -1 self.buttons = [] modal=True if modal: setTransient(self, parent) # settings if width > 0 or height > 0: self.set_size_request(width, height) #self.window.resize(width, height) self.set_title(title) # self.connect('key-press-event', self._keyPressEvent)
def __init__(self, app, parent, title=None, images=None, color="blue", width=300, height=25, show_text=1, norm=1): self.parent = parent self.percent = 0 self.top = makeToplevel(parent, title=title) self.top.wm_protocol("WM_DELETE_WINDOW", self.wmDeleteWindow) self.top.wm_group(parent) self.top.wm_resizable(False, False) self.frame = Tkinter.Frame(self.top, relief='flat', bd=0, takefocus=0) self.cframe = Tkinter.Frame(self.frame, relief='sunken', bd=1, takefocus=0) self.canvas = Tkinter.Canvas(self.cframe, width=width, height=height, takefocus=0, bd=0, highlightthickness=0) self.scale = self.canvas.create_rectangle(-10, -10, 0, height, outline=color, fill=color) self.text = -1 if show_text: self.text = self.canvas.create_text(0, 0, anchor=Tkinter.CENTER) self.cframe.grid_configure(column=0, row=0, sticky="ew") if images: self.f1 = Tkinter.Label(self.frame, image=images[0]) self.f1.grid_configure(column=0, row=0, sticky="ew", ipadx=8, ipady=4) self.cframe.grid_configure(column=1, row=0, sticky="ew", padx=8) self.f2 = Tkinter.Label(self.frame, image=images[1]) self.f2.grid_configure(column=2, row=0, sticky="ew", ipadx=8, ipady=4) self.top.config(cursor="watch") self.pack() if 1: setTransient(self.top, None, relx=0.5, rely=0.5) else: self.update(percent=0) self.norm = norm self.steps_sum = 0
def __init__(self, app, parent, title=None, images=None, color='blue', bg='#c0c0c0', height=25, show_text=1, norm=1): self.parent = parent self.percent = 0 self.steps_sum = 0 self.norm = norm self.top = makeToplevel(parent, title=title) self.top.set_position(gtk.WIN_POS_CENTER) self.top.set_resizable(False) self.top.connect("delete_event", self.wmDeleteWindow) # hbox hbox = gtk.HBox(spacing=5) hbox.set_border_width(10) hbox.show() self.top.table.attach(hbox, 0, 1, 0, 1, 0, 0, 0, 0) # hbox-1: image if images and images[0]: im = gtk.Image() im.set_from_pixbuf(images[0].pixbuf) hbox.pack_start(im, expand=False, fill=False) im.show() im.set_property('xpad', 10) im.set_property('ypad', 5) # hbox-2:vbox vbox = gtk.VBox() vbox.show() hbox.pack_start(vbox, False, False) # hbox-2:vbox:pbar self.pbar = gtk.ProgressBar() self.pbar.show() vbox.pack_start(self.pbar, True, False) self.pbar.realize() # ~ self.pbar.set_show_text(show_text) self.pbar.set_text(str(show_text) + '%') w, h = self.pbar.size_request() self.pbar.set_size_request(max(w, 300), max(h, height)) # hbox-3:image if images and images[1]: im = gtk.Image() im.set_from_pixbuf(images[1].pixbuf) hbox.pack_end(im, expand=False) im.show() im.set_property('xpad', 10) im.set_property('ypad', 5) setTransient(self.top, parent) self.top.show() self.top.window.set_cursor(gdk.Cursor(gdk.WATCH)) self.update(percent=0)
def createColorsel(self): win = gtk.ColorSelectionDialog(_('Select table color')) win.help_button.destroy() win.set_position(gtk.WIN_POS_CENTER_ON_PARENT) if isinstance(self.preview_key, str): color = self.preview_key else: color = self.app.opt.colors['table'] win.colorsel.set_current_color(gdk.color_parse(color)) win.connect('delete_event', lambda w, e: win.destroy()) win.ok_button.connect('clicked', self._colorselOkClicked, win) win.cancel_button.connect('clicked', lambda w: win.destroy()) setTransient(win, self) win.show()
def mainloop(self, focus=None, timeout=0): bind(self.top, "<Escape>", self.mCancel) if focus is not None: focus.focus() setTransient(self.top, self.parent) try: self.top.grab_set() except Tkinter.TclError: pass if timeout > 0: self.timer = after(self.top, timeout, self.mTimeout) try: self.top.mainloop() except SystemExit: pass self.destroy()
def mainloop(self, focus=None, timeout=0, transient=True): bind(self.top, "<Escape>", self.mCancel) bind(self.top, '<Alt-Key>', self.altKeyEvent) # for accelerators if focus is not None: focus.focus() if transient: setTransient(self.top, self.parent) try: self.top.grab_set() except Tkinter.TclError: if traceback: traceback.print_exc() pass if timeout > 0: self.timer = after(self.top, timeout, self.mTimeout) try: self.top.mainloop() except SystemExit: pass self.destroy()
def __init__(self, app, parent, title=None, images=None, color='blue', bg='#c0c0c0', height=25, show_text=1, norm=1): self.parent = parent self.percent = 0 self.steps_sum = 0 self.norm = norm self.top = makeToplevel(parent, title=title) self.top.set_position(gtk.WIN_POS_CENTER) self.top.set_resizable(False) self.top.connect("delete_event", self.wmDeleteWindow) # hbox hbox = gtk.HBox(spacing=5) hbox.set_border_width(10) hbox.show() self.top.table.attach(hbox, 0, 1, 0, 1, 0, 0, 0, 0) # hbox-1: image if images and images[0]: im = gtk.Image() im.set_from_pixbuf(images[0].pixbuf) hbox.pack_start(im, expand=False, fill=False) im.show() im.set_property('xpad', 10) im.set_property('ypad', 5) # hbox-2:vbox vbox = gtk.VBox() vbox.show() hbox.pack_start(vbox, False, False) # hbox-2:vbox:pbar self.pbar = gtk.ProgressBar() self.pbar.show() vbox.pack_start(self.pbar, True, False) self.pbar.realize() # ~ self.pbar.set_show_text(show_text) self.pbar.set_text(str(show_text)+'%') w, h = self.pbar.size_request() self.pbar.set_size_request(max(w, 300), max(h, height)) # hbox-3:image if images and images[1]: im = gtk.Image() im.set_from_pixbuf(images[1].pixbuf) hbox.pack_end(im, expand=False) im.show() im.set_property('xpad', 10) im.set_property('ypad', 5) # set icon # if app: # try: # name = app.dataloader.findFile('pysol.xpm') # bg = self.top.get_style().bg[gtk.STATE_NORMAL] # pixmap, mask = create_pixmap_from_xpm(self.top, bg, name) # self.top.set_icon(pixmap, mask) # except: pass setTransient(self.top, parent) self.top.show() self.top.window.set_cursor(gdk.Cursor(gdk.WATCH)) self.update(percent=0)