class AboutPopUp(): ''' there is a lot of work to do here also, but is a quite good and functional starting point... first put as child of Toplevel then change to grid ''' def __init__(self, **kwargs): ''' (under development)''' master = None title = 'AboutPopUp' licence = None if 'master' in kwargs.keys(): master = kwargs['master'] if 'title' in kwargs.keys(): title = kwargs['title'] if 'licence' in kwargs.keys(): licence = kwargs['licence'] self.im_smlogo = PhotoImage(file="./lib/gui/img/small_logo2.ppm") self.im_logo2 = PhotoImage(file="./lib/gui/img/logo2.ppm") self.master = master self._title_ = title self._licence_ = licence self.set_self_vertex() self.create_content() def set_self_vertex(self): ws, hs, w_main, h_main, x_main, y_main = self.master.MAINVERTEX # calculate the greatness w_pop = w_main h_pop = h_main * 14 / 21 x_pop = x_main + w_main + 30 y_pop = y_main + h_main - h_pop - 140 #print w_pop, h_pop, x_pop, y_pop self._vertex_ = [w_pop, h_pop, x_pop, y_pop] def create_content(self): self.pop = Toplevel(self.master, bg="white") self.pop.grab_set() # when you show the popup self.pop.wm_title(' ' * 5 + self._title_) self.pop.geometry('{:d}x{:d}+{:d}+{:d}'.format(*self._vertex_)) leftcolumn = Frame(self.pop, bg="white") Label(leftcolumn, bg="white").pack(side="top", fill="both", pady=30) Label(leftcolumn, bg="white", image=self.im_logo2).pack(side="top", fill="both", padx=10) #side= LEFT, leftcolumn.pack(side="left", fill='both', padx=1) rightcolumn = Frame(self.pop, bg="white") firstrow = Frame(rightcolumn, bg="white") Frame(rightcolumn, bg="white").pack(side="top", pady=10, padx=0) Label(firstrow, text="GROTOLAM", fg="Gray13", bg="white", font="Verdana 13 bold").pack(side="left", pady=20) Label(firstrow, text='', bg="white").pack(side="left", padx=40) firstrow.pack(side="top", padx=0) secrow = Frame(rightcolumn, bg="white") Label(secrow, text="v " + __version__.split()[2], fg="Gray13", bg="white", font="Verdana 10").pack(side="left") Label(secrow, text='', bg="white").pack(side="left", padx=75) secrow.pack(side="top", padx=0) # lets create space to do some stuff ... Frame(rightcolumn, bg="white").pack(side="top", pady=20, padx=0) thirdrow = Frame(rightcolumn, bg="white") Label(thirdrow, text="2018 Python version by", fg="Gray13", bg="white", font="Verdana 10").pack(side="left") Label(thirdrow, text='', bg="white").pack(side="left", padx=16) thirdrow.pack(side="top", padx=0) fourthrow = Frame(rightcolumn, bg="white") Label(fourthrow, text="Hernan Chavez Thielemann", fg="Gray13", bg="white", font="Verdana 10").pack(side="left") Label(fourthrow, text='', bg="white").pack(side="left", padx=1) fourthrow.pack(side="top", padx=0) fifthrow = Frame(rightcolumn, bg="white") Label(fifthrow, bg="white", image=self.im_smlogo).pack(side="left", fill="both", padx=10) fifthrow.pack(side="top", padx=0) sixthrow = Frame(rightcolumn, bg="white") href = Label(sixthrow, bg="white", font="Verdana 10", text="Small web page", fg="blue", cursor="hand2") f = Font(href, href.cget("font")) f.configure(underline=True) href.configure(font=f) href.pack(side="left") href.bind("<Button-1>", self.callback) Label(sixthrow, text='', bg="white").pack(side="left", padx=40) sixthrow.pack(side="top", padx=0) lastrow = Frame(rightcolumn, bg="white") self.bottom_button_row(lastrow) rightcolumn.pack(side="right", fill='both', padx=5) def callback(self, event): open_new(r"http://www.polito.it/small") def bottom_button_row(self, _row_): b2 = Button(_row_, text='Close', bg="white", command=self.exit_pop) b2.pack(side="right", padx=10, pady=4) b1 = Button(_row_, text='Licence', bg="white", command=self._licence_) b1.pack(side="right", padx=10, pady=20) _row_.pack(side="bottom") def openlicence(self): print 'opening licence file' def exit_pop(self): self.pop.grab_release() # to return to normal self.pop.destroy()
class PromptPopUp_old(): '''the future description: "Neat & tidy prompt pop up to request input" there is a lot of work to do here : make it class clean functions to make it generic add extra parameters such as: buttons title dimensions* >but is a functional starting point< ''' def __init__(self, **kwargs): ''' (under development)''' master = None briefing = '' entries_txt = [] entries_val = [] title = 'PromptPopUp' if 'master' in kwargs.keys(): master = kwargs['master'] if 'briefing' in kwargs.keys(): briefing = kwargs['briefing'] if 'entries_txt' in kwargs.keys(): entries_txt = kwargs['entries_txt'] if 'entries_val' in kwargs.keys(): entries_val = kwargs['entries_val'] if 'title' in kwargs.keys(): title = kwargs['title'] self.master = master self._briefing_ = briefing self._entries_ = entries_txt self._defvals_ = entries_val self._title_ = title self.ent_c = [] self.set_self_vertex() self.create_content() def set_self_vertex(self): from main_gui import MAINVERTEX ws, hs, w_main, h_main, x_main, y_main = MAINVERTEX # calculate the greatness self.entr_maxlen = int(len(max(self._entries_, key=len)) * 2.25 / 3.0) w_pop = w_main - 40 h_pop = h_main * 12 / 21 x_pop = x_main + w_main - 30 y_pop = y_main + h_main - h_pop #print w_pop, h_pop, x_pop, y_pop self._vertex_ = [w_pop, h_pop, x_pop, y_pop] def create_content(self): self.pop = Toplevel(self.master) self.pop.grab_set() # when you show the popup self.pop.wm_title(' ' * 20 + self._title_) self.pop.geometry('{:d}x{:d}+{:d}+{:d}'.format(*self._vertex_)) label0 = Label(self.pop, text=self._briefing_) label0.pack(side="top", fill="both", expand=True, padx=100, pady=20) # just a line bottom_hline_deco(self.pop) # lets create space to do some stuff ... row2fill = Frame(self.pop) for e in range(len(self._entries_)): self.ent_c.append( create_entry(row2fill, self._entries_[e], self._defvals_[e], self.entr_maxlen)) row2fill.pack(side="top", padx=1, pady=5) self.bottom_button_row() self.master.solv_b.config(bg='gray40', width=45) #cyan') #self.master.solv_b.flash() #self.pop.mainloop() def bottom_button_row(self): _br_ = Frame(self.pop) b1 = Button(_br_, text='Save', command=(lambda: self.save_it())) b1.pack(side="right", padx=10, pady=20) b2 = Button(_br_, text='Quit', command=(lambda: self.exit_pop())) b2.pack(side="right", padx=10, pady=4) _br_.pack(side="bottom", expand=True) def save_it(self): self.master._solvatedinfo_ = get_entriesvalue(self.ent_c) self.exit_pop() def exit_pop(self): self.pop.grab_release() # to return to normal self.master.solv_b.config(bg='lightgrey', width=29) self.pop.destroy()