Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter as tk
- import tkinter.font as tkFont
- import tkinter.ttk as ttk
- import tkinter.scrolledtext as scrolledtext
- SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
- 1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']}
- def approximate_size(size, a_kilobyte_is_1024_bytes=True):
- '''Convert a file size to human-readable form.
- Keyword arguments:
- size -- file size in bytes
- a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024
- if False, use multiples of 1000
- Returns: string
- '''
- if size < 0:
- raise ValueError('number must be non-negative')
- multiple = 1024 if a_kilobyte_is_1024_bytes else 1000
- for suffix in SUFFIXES[multiple]:
- size /= multiple
- if size < multiple:
- return '{0:.1f} {1}'.format(size, suffix)
- raise ValueError('number too large')
- if __name__ == '__main__':
- print(approximate_size(1000000000000, False))
- print(approximate_size(1000000000000))
- LARGE_FONT= ("Verdana", 12)
- class SeaofBTCapp(tk.Tk):
- def __init__(self, *args, **kwargs):
- tk.Tk.__init__(self, *args, **kwargs)
- container = tk.Frame(self)
- container.pack(side="top", fill="both", expand = True)
- container.grid_rowconfigure(0, weight=1)
- container.grid_columnconfigure(0, weight=1)
- self.frames = {}
- for F in (StartPage, PageOne, PageTwo, PageTre, PageFour, PageFive, PageSix, PageSeven, PageEight,):
- frame = F(container, self)
- self.frames[F] = frame
- frame.grid(row=0, column=0, sticky="nsew")
- self.show_frame(StartPage)
- def show_frame(self, cont):
- frame = self.frames[cont]
- frame.tkraise()
- top = Tk()
- top.geometry("100x300+1600+120")
- mb = Menubutton ( top, text = "condiments", relief = RAISED )
- mb.grid()
- mb.menu = Menu ( mb, tearoff = 0 )
- mb["menu"] = mb.menu
- mayoVar = IntVar()
- ketchVar = IntVar()
- mb.menu.add_checkbutton ( label = "mayo",
- variable = mayoVar )
- mb.menu.add_checkbutton ( label = "ketchup",
- variable = ketchVar )
- from tkinter import *
- def donothing():
- filewin = Toplevel(root)
- button = Button(filewin, text="Do nothing button")
- button.pack()
- root = Tk()
- root.geometry("200x300+150+20")
- menubar = Menu(root)
- filemenu = Menu(menubar, tearoff = 0)
- filemenu.add_command(label="New", command = donothing)
- filemenu.add_command(label = "Open", command = donothing)
- filemenu.add_command(label = "Save", command = donothing)
- filemenu.add_command(label = "Save as...", command = donothing)
- filemenu.add_command(label = "Close", command = donothing)
- filemenu.add_separator()
- filemenu.add_command(label = "Exit", command = root.quit)
- menubar.add_cascade(label = "File", menu = filemenu)
- editmenu = Menu(menubar, tearoff=0)
- editmenu.add_command(label = "Undo", command = donothing)
- editmenu.add_separator()
- editmenu.add_command(label = "Cut", command = donothing)
- editmenu.add_command(label = "Copy", command = donothing)
- editmenu.add_command(label = "Paste", command = donothing)
- editmenu.add_command(label = "Delete", command = donothing)
- editmenu.add_command(label = "Select All", command = donothing)
- menubar.add_cascade(label = "Edit", menu = editmenu)
- helpmenu = Menu(menubar, tearoff=0)
- helpmenu.add_command(label = "Help Index", command = donothing)
- helpmenu.add_command(label = "About...", command = donothing)
- menubar.add_cascade(label = "Help", menu = helpmenu)
- root.config(menu = menubar)
- window = tk.Tk() # tworzenie okna głównego
- window.title( "Hello World" ) # ustawienie tytułu okna głównego
- # tworzenie kontrolki typu label
- window.geometry("1000x800+500+20")
- label = tk.Label( window, text = "Witaj Świecie programowania\nCo swym urokiemnas zabawia\nCo otwiera nowe możliwości\nZ binarnych liczb złożoności" )
- label.pack( side = tk.BOTTOM ) # podpinanie kontrolki pod okno
- class GUI(object):
- def __init__(self):
- root = self.root = tkinter.Tk()
- root.title('Test')
- # make the top right close button minimize (iconify) the main window
- root.protocol("WM_DELETE_WINDOW", root.iconify)
- # make Esc exit the program
- root.bind('<Escape>', lambda e: root.destroy())
- # create a menu bar with an Exit command
- menubar = tkinter.Menu(root)
- filemenu = tkinter.Menu(menubar, tearoff=0)
- filemenu.add_command(label="Exit", command=root.destroy)
- menubar.add_cascade(label="File", menu=filemenu)
- root.config(menu=menubar)
- # create a Text widget with a Scrollbar attached
- txt = scrolledtext.ScrolledText(root, undo=True)
- txt['font'] = ('consolas', '12')
- txt.pack(expand=True, fill='both')
- gui = GUI()
- class StartPage(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self,parent)
- label = tk.Label(self, text="glowna strona", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="omnie",
- command=lambda: controller.show_frame(PageOne))
- button.pack()
- button2 = tk.Button(self, text="biblioteka",
- command=lambda: controller.show_frame(PageTwo))
- button2.pack()
- button3 = tk.Button(self, text="cwiczenia",
- command=lambda: controller.show_frame(PageTre))
- button3.pack()
- button4 = tk.Button(self, text="drewno i wegiel",
- command=lambda: controller.show_frame(PageTre))
- button4.pack()
- button5 = tk.Button(self, text="przeczytane",
- command=lambda: controller.show_frame(PageTre))
- button5.pack()
- button6 = tk.Button(self, text="sumawydatkow",
- command=lambda: controller.show_frame(PageTre))
- button6.pack()
- button7 = tk.Button(self, text="szkola",
- command=lambda: controller.show_frame(PageTre))
- button7.pack()
- button8 = tk.Button(self, text="telefon",
- command=lambda: controller.show_frame(PageTre))
- button8.pack()
- class PageOne(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageTwo(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageTre(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageFour(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageFive(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageSix(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageSeven(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- class PageEight(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- label = tk.Label(self, text="Page One!!!", font=LARGE_FONT)
- label.pack(pady=10,padx=10)
- button = tk.Button(self, text="glowna",
- command=lambda: controller.show_frame(StartPage))
- button.pack()
- app = SeaofBTCapp()
- app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement