Ich weiß nicht, ob command=self.ngag_page(page) richtig ausgedrückt ist, anders wüsste ich allerdings nicht, wie ich 'hot' als page benutze, sobald man den Button drückt, da ich selbiges auch mit 'trending' und 'vote' machen möchte.
Code: Alles auswählen
import os, time
from Tkinter import Tk, Label, Toplevel, Frame, Button
root=Tk()
class App():
def __init__(self, master):
self.bgcolor="#5ca1f7"
self.ngag_toplevel = Toplevel(bg=self.bgcolor)
self.ngag_toplevel.geometry('640x360')
self.ngag_toplevel.title('9gag Downloader')
self.ngag_toplevel.focus_force()
self.ngag_toplevel.resizable(False, False)
self.ngag_toplevel.wm_attributes("-topmost", True)
self.ngag_toplevel.attributes("-alpha", 0.95)
self.ngag_frame = Frame(self.ngag_toplevel, bg=self.bgcolor)
self.ngag_frame.pack(fill='both', expand=True)
self.ngag_button_hot = Button(self.ngag_frame, text='Hot', width=8, command=self.ngag_page('hot'))
self.ngag_button_hot.pack(side='top', anchor='w', padx=15, pady=10)
self.ngag_button_trend = Button(self.ngag_frame, text='Trending', width=8)
self.ngag_button_trend.pack(side='top', anchor='w', padx=15, pady=0)
self.ngag_button_vote = Button(self.ngag_frame, text='Vote', width=8)
self.ngag_button_vote.pack(side='top', anchor='w', padx=15, pady=10)
def ngag_page(self, page):
zeit=time.localtime()
jahr, monat, tag, stunde, minute = zeit[0:5]
self.folder= "%s-%s-%s-%s-%s" % (tag, monat, jahr, stunde, minute)
url='http://9gag.com/%s' % page
name = '%s'+str(time.time())
os.makedirs('9gag\\%s_%s' % (page[0], self.folder))
App(root)
root.mainloop()
Stefan
Vielen Dank für Antworten (und Entschuldigung für die vielen Fragen, die ich ständig stelle :/ Ich versuche wirklich, nur Fragen zu stellen, wenn ich selbst nach Tagen nicht herausfinde, was das Problem ist.)