Example #1
0
def new_window(title='', width=-1, height=-1, icon='', resizable=True):
    root = Tk()
    if title == '': pass
    else: root.title(title)
    if width == -1 or height == -1: pass
    else: root.geometry(str(width) + 'x' + str(height))
    if icon == '': pass
    else: root.call('wm', 'iconphoto', root._w, PhotoImage(file=str(icon)))
    if resizable == True: pass
    else: root.resizable(resizable, resizable)
    return root
Example #2
0
def show_error(err):
    root = Tk()
    root.title('Error')
    try:
        root.call('wm', 'iconphoto', root._w, PhotoImage(file='ico.png'))
    except Exception:
        print 'Error loading icon'
    root.geometry('200x100+100+100')
    root.overrideredirect(True)

    Label(root, text=err).place(x=0, y=0, height=50, relwidth=1.0)

    Button(root, text='Ok', command=lambda: exit(root)).place(x=60,
                                                              y=60,
                                                              height=30,
                                                              width=80)

    root.mainloop()
Example #3
0
def guiLogin():
    root = Tk()

    root.title("Enter Lastpass login")

    mainframe = ttk.Frame(root, padding="3 3 12 12")
    mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
    mainframe.columnconfigure(0, weight=1)
    mainframe.rowconfigure(0, weight=1)

    username = StringVar()
    password = StringVar()
    ret = []

    def done(*args):
        ret.append((username.get(), password.get()))
        root.destroy()

    ttk.Label(mainframe, text="Username:"******"Password:"******"Login", command=done).grid(column=2,
                                                           row=3,
                                                           sticky=W)

    for child in mainframe.winfo_children():
        child.grid_configure(padx=5, pady=2)

    username_entry.focus()
    root.bind('<Return>', done)
    root.bind('<Escape>', lambda event: root.destroy())

    root.lift()
    root.call('wm', 'attributes', '.', '-topmost', True)
    root.after_idle(root.call, 'wm', 'attributes', '.', '-topmost', False)

    root.mainloop()

    return ret and ret[-1] or None
Example #4
0
def show_word(word):
    t = time()
    select = [0]
    root = Tk()
    root.title('CrazyEnglish')
    try:
        root.call('wm', 'iconphoto', root._w, PhotoImage(file='english.png'))
    except Exception:
        print 'Error loading icon'
    root.geometry(
        str(root.winfo_screenwidth()) + 'x' + str(root.winfo_screenheight()) +
        '+0+0')  #root.winfo_screenheight()
    root.resizable(False, False)
    root.protocol('WM_DELETE_WINDOW', lambda: exit(root, select))

    canvas = Canvas(root)  #,bg='green')
    canvas.place(x=100, y=100, width=800, height=50)

    canvas.create_text(0,
                       0,
                       text=word[0],
                       anchor='nw',
                       font=('', 14),
                       fill='red')
    canvas.create_text(0, 30, text='(' + word[1] + ')', anchor='nw')

    entry = Entry(root, font=('', 10))
    entry.place(x=100, y=200, width=800, height=30)

    Button(root, text='OK',
           command=lambda: press_btn(root, entry, word[0])).place(x=100,
                                                                  y=250,
                                                                  height=30,
                                                                  width=80)

    root.after(0, lambda: close_window(root, t))

    entry.focus_force()

    root.mainloop()

    return select[0]
Example #5
0
#!/usr/bin/python
from Tkinter import Tk, PhotoImage, Canvas, Label, IntVar
from time import sleep
from math import acos, degrees
from re import sub
from threading import Thread
from random import randrange

mainframe = Tk()
mainframe.title('LINE')
mainframe.geometry('490x544')
mainframe.call('wm', 'iconphoto', mainframe._w,
               PhotoImage(file='data/ico.png'))
mainframe.resizable(False, False)


def mainexit():
    global cv, cv_frame, viewer, select_ball
    del cv
    del cv_frame
    del viewer
    select_ball[0] = -1
    mainframe.destroy()


mainframe.protocol('WM_DELETE_WINDOW', mainexit)
cv_bg_color = '#d5d5d5'
cv_frame = Canvas(mainframe)  #,bg=cv_bg_color
cv_frame.place(x=0, y=0, relwidth=1.0, relheight=1.0)
point = 0
point_max = 0
Example #6
0
    root = Tk()
    root.title('MineSweeper')
    root.geometry(str(size_game[0] * 25) + 'x' + str(size_game[1] * 25 + 45))
    root.resizable(False, False)
    root.protocol('WM_DELETE_WINDOW', e)
    #i=PhotoImage(file='data/ico.png')
    #root.call('wm','iconphoto',root._w,i)

    import main
    from header import header
    from img import load_img
    flag_number = [boom_number[0]]
    game_status = ['normal']
    img = load_img()

    root.call('wm', 'iconphoto', root._w, img['icon'])

    h = header()
    h.frame = [Canvas(root)]
    h.frame[0].place(x=0, y=10, height=25, relwidth=1.0)
    h.flag_number = flag_number
    h.img = img
    h.exit = exit
    h.status = game_status
    h.list_cell = main.list_cell
    h.size_game = size_game

    main.frame = [Canvas(root)]
    main.frame[0].place(x=0, y=45, height=size_game[1] * 25, relwidth=1.0)
    main.flag_number = flag_number
    main.img = img
Example #7
0
class gui:
	
	status=Queue()
	
	def __init__(self):
	
		self.onoff=0
		self.__gui_create()
		
	
	def __gui_create(self):
		self.root=Tk()
		self.root.title('ClickNEOBUX')
		w=self.root.winfo_screenwidth()-180
		h=self.root.winfo_screenheight()-50
		self.root.geometry('180x80+'+str(w)+'+'+str(h))
		self.root.resizable(False,False)
		self.root.protocol('WM_DELETE_WINDOW',self.__gui_exit)
		try:
			self.root.call('wm','iconphoto',self.root._w,PhotoImage(file='data/neobux.png'))
		except Exception:
			print 'Error loading icon'
	
		self.text_btn=StringVar()
		self.text_btn.set('Start')
		Button(self.root,textvariable=self.text_btn,command=self.__gui_click_btn).place(x=50,y=10,height=30,width=80)
	
		self.text_lb=StringVar()
		self.text_lb.set('Pausing ...')
		Label(self.root,textvariable=self.text_lb).place(x=0,y=50,width=180,height=30)
		
		#self.root.after(0,self.__check_status)
		
		self.root.mainloop()
		print 'Exit GUI'
		
		
	def __gui_exit(self):
		if self.onoff in [0,1]:
			self.root.destroy()
			self.proc.terminate()
		else: print 'Clicking ...'
		
	
	def __gui_click_btn(self):
		if self.onoff==0:
			self.text_btn.set('Pause')
			self.text_lb.set('Starting ...')
			self.onoff=1
			self.proc=Process(target=click_manager,args=(self.status,))
			self.proc.start()
			self.__check_status()
		elif self.onoff==1:
			self.text_btn.set('Start')
			self.text_lb.set('Pausing ...')
			self.onoff=0
			self.proc.terminate()
			self.proc.exitcode
			
			
	def __check_status(self):
		status=''
		try:
			status=self.status.get(False)
		except Exception:
			pass
		else:
			self.text_lb.set(status)
		finally:
			if self.onoff!=0:
				if not self.proc.is_alive():
					self.proc=Process(target=click_manager,args=(self.status,))
					self.proc.start()
				self.root.after(100,self.__check_status)
Example #8
-1
def guiLogin(title, default_username="", default_password=""):
    from Tkinter import Tk, N, S, W, E, StringVar
    import ttk

    root = Tk()

    root.title(title)

    mainframe = ttk.Frame(root, padding="3 3 12 12")
    mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
    mainframe.columnconfigure(0, weight=1)
    mainframe.rowconfigure(0, weight=1)

    username = StringVar()
    username.set(default_username)
    password = StringVar()
    password.set(default_password)

    def done(*args):
        root.destroy()

    ttk.Label(mainframe, text="Username:"******"Password:"******"*")
    pass_entry.grid(column=2, row=2, sticky=(W, E))

    ttk.Button(mainframe, text="Login", command=done).grid(column=2, row=3, sticky=W)

    for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=2)

    username_entry.focus()
    root.bind('<Return>', done)
    root.bind('<Escape>', lambda event: root.destroy())

    root.lift()
    root.call('wm', 'attributes', '.', '-topmost', True)
    root.after_idle(root.call, 'wm', 'attributes', '.', '-topmost', False)

    root.mainloop()

    return username.get(), password.get()
Example #9
-1
def guiLogin():
    root = Tk()

    root.title("Enter Lastpass login")

    mainframe = ttk.Frame(root, padding="3 3 12 12")
    mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
    mainframe.columnconfigure(0, weight=1)
    mainframe.rowconfigure(0, weight=1)

    username = StringVar()
    password = StringVar()
    ret = []

    def done(*args):
        ret.append((username.get(), password.get()))
        root.destroy()

    ttk.Label(mainframe, text="Username:"******"Password:"******"Login", command=done).grid(column=2, row=3, sticky=W)

    for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=2)

    username_entry.focus()
    root.bind('<Return>', done)
    root.bind('<Escape>', lambda event: root.destroy())

    root.lift()
    root.call('wm', 'attributes', '.', '-topmost', True)
    root.after_idle(root.call, 'wm', 'attributes', '.', '-topmost', False)

    root.mainloop()

    return ret and ret[-1] or None