اون PyGTK را که خدا بیامرزه! ولی از بین کیوت و GTK من GTK را ترجیح میدم که میشه PyGobject!
چرا کلید select all من کار نمیکنه؟ و همه لیست انخاب نمیکنه؟
import gi # GObject UI Generator for Python
import requests # for get site html content
import bs4 # for process html content for finding film
# http://dl11.imovie-dl.in/Serial/Game-Of-Thrones/S01/480p-HDTV/
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject
# fetch url links
def links(url):
__url = str(url) # find_dl_url()
__page = requests.get(__url)
__page_content = bs4.BeautifulSoup(__page.content)
__links = __page_content.select('a[href*=".mkv"]')
__dict = {}
__sorted_dict = {}
__list = []
for x in __links:
__dict[x.string] = x.get('href')
__list.append(x.string)
__list = sorted(__list)
return __list, __dict
#this is for list box and at the moment i have no idea what this shit is
class ListBoxRowWithData(Gtk.ListBoxRow):
def __init__(self, data):
super(Gtk.ListBoxRow, self).__init__()
self.data = data
self.add(Gtk.Label(data))
class linkswindow(Gtk.Window): # cooose wich links needs to download
def __init__(self,list0,dict0):
Gtk.Window.__init__(self, title="Choose links")
self.set_size_request(100, 50)
box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
self.add(box_outer)
__list = list0
__dict = dict0
# print(__list,__dict)
# ######choose what episode u wanna download:###
self.listbox = Gtk.ListBox()
for items in __list:
self.listbox.add(ListBoxRowWithData(items))
self.listbox.connect('row-activated',lambda widget, row:print(row.data))
box_outer.pack_start(self.listbox, True, True, 0)
self.listbox.set_selection_mode(3)
self.listbox.show_all()
# buttun stuff
vbox = Gtk.Box()
box_outer.pack_start(vbox, True, True, 0)
# self.add(self.vbox)
select_all_button =Gtk.Button(label="Select All")
select_all_button.connect("clicked", self.on_select_all_clicked)
vbox.pack_start(select_all_button,True, True,0)
select_none_button =Gtk.Button(label="Select None")
select_none_button.connect("clicked", self.on_select_none_clicked)
vbox.pack_start(select_none_button,True, True, 0)
exit_button= Gtk.Button(label="Exit")
exit_button.connect("clicked", self.on_exit_clicked)
vbox.pack_start(exit_button, True, True, 0)
def on_select_all_clicked(self,button):
self.listbox.do_select_all()
def on_select_none_clicked(self, button):
self.listbox.do_unselect_all(1)
def on_exit_clicked(self, button):
exit()
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="PyMovie")
self.set_size_request(100, 10)
self.set_border_width(10)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
# print(dir(vbox.props)) # shows commands can use for object
self.add(vbox)
self.linkUrl = Gtk.Entry()
vbox.pack_start(self.linkUrl, True, True, 0)
vbox.pack_end(self.linkUrl, True, True, 0)
# hbox = Gtk.Box(spacing=6)
# vbox.pack_start(hbox, True, True, 0)
hbox = Gtk.Box(spacing=6)
vbox.pack_start(hbox, True, True, 0)
self.passwordimovie = Gtk.Entry()
self.passwordimovie.set_text("password")
self.passwordimovie.set_visibility(False)
hbox.pack_start(self.passwordimovie, True, True, 1)
self.userMovie = Gtk.Entry()
self.userMovie.set_text("user")
hbox.pack_start(self.userMovie, True, True, 1)
hbox2 = Gtk.Box(spacing=6)
vbox.pack_start(hbox2, True, True, 0)
button = Gtk.Button.new_with_label("Click Me")
button.connect("clicked", self.on_click_me_clicked)
hbox2.pack_start(button, True, True, 0)
button.set_border_width(10)
######## exit button
exitbutton = Gtk.Button.new_with_label("exit")
exitbutton.connect("clicked", self.on_exit_clicked)
hbox2.pack_start(exitbutton, True, True, 0)
############### end exit button
def on_click_me_clicked(self, button):
self.link = self.linkUrl.get_text()
self.userName = self.userMovie.get_text()
self.userPass = self.passwordimovie.get_text()
lst,dct = links(self.link)
# print(lst , dct)
winlink = linkswindow(lst , dct)
winlink.connect("delete-event", Gtk.main_quit)
winlink.show_all()
Gtk.main()
########## on exit click method
def on_exit_clicked(self, button):
print("1")
exit()
win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
داکیومنتش ایجاس
http://13x.ir/B2ولی من هیچ چی ازش نمیفهمم.