Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Color Palette
- self.bg_color = "#336699"
- self.button_color = "#4CAF50"
- self.text_color = "white"
- ----------------------------------------------
- self.title_label = tk.Label(self.main_frame, text="NAJEEB VIDEO PLAYER", font=("Arial", 24, "bold"), fg=self.text_color, bg=self.bg_color)
- self.title_label.pack(pady=10)
- --------------------------------------------------------------------
- self.search_button = tk.Button(self.search_frame, text="Search YouTube", command=self.search_and_play, bg=self.button_color, fg=self.text_color)
- self.search_button.pack(side="left", padx=5, pady=5)
- self.save_button = tk.Button(self.search_frame, text="Save", command=self.save_results, bg=self.button_color, fg=self.text_color)
- self.save_button.pack(side="left", padx=5, pady=5)
- -----------------------------------------------------------------------------
- self.prev_button = tk.Button(self.button_frame, text="Prev", command=self.prev_page, bg=self.button_color, fg=self.text_color)
- self.prev_button.pack(side="left", padx=5, pady=5)
- self.next_button = tk.Button(self.button_frame, text="Next", command=self.next_page, bg=self.button_color, fg=self.text_color)
- self.next_button.pack(side="left", padx=5, pady=5)
- self.play_button = tk.Button(self.button_frame, text="Play", command=self.play_video, bg=self.button_color, fg=self.text_color)
- self.play_button.pack(side="left", padx=5, pady=5)
- self.stop_button = tk.Button(self.button_frame, text="Stop", command=self.stop_video, bg=self.button_color, fg=self.text_color)
- self.stop_button.pack(side="left", padx=5, pady=5)
- self.current_video_label = tk.Label(root, text="No video selected", bg=self.bg_color, fg=self.text_color)
- self.current_video_label.pack(pady=5)
- self.time_label = tk.Label(root, text="", bg=self.bg_color, fg=self.text_color)
- self.time_label.pack(pady=5)
- self.slider = tk.Scale(root, from_=0, to=100, orient="horizontal", bg=self.bg_color, fg=self.text_color, command=self.set_video_position)
- self.slider.pack(fill="x")
- ------------------------------------------------------------------------
- root = tk.Tk()
- root.geometry("800x600+300+50")
- root.title("Najeeb VLC Player")
- root.configure(bg="#336699")
- video_player = VideoPlayer(root)
- root.mainloop()
- --------------------------------------------------
- # Create the main application window
- app = tk.Tk()
- app.title("Najeeb IPTV Channel Search M3u All Category")
- app.geometry("800x600")
- app.configure(bg="#336699")
- -------------------------------------------------------------------------------
- # Add labels, entry fields, buttons, etc.
- url_frame = tk.Frame(app, bg="#336699")
- url_frame.pack(pady=10)
- url_label = tk.Label(url_frame, text="Enter URL 0R local OR Select Category:", bg="#336699", fg="white")
- url_label.pack(side=tk.LEFT, padx=5)
- url_entry = tk.Entry(url_frame, width=80) # Adjust width here
- url_entry.pack(side=tk.LEFT, padx=5)
- search_button = tk.Button(url_frame, text="Search", command=search_channels, bg="#FFA500", fg="white")
- search_button.pack(side=tk.LEFT, padx=5)
- result_label = tk.Label(app, text="Najeeb Iptv Channels Run Vlc Player Check Working Or Not Working And save Working URLS in M3U File:", bg="#336699", fg="white")
- result_label.pack()
- # Add scrollbar to the listbox
- scrollbar = tk.Scrollbar(app, orient=tk.VERTICAL)
- scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
- result_text = tk.Listbox(app, height=30, width=130, yscrollcommand=scrollbar.set)
- result_text.pack()
- # Configure scrollbar
- scrollbar.config(command=result_text.yview)
- # Bind double click event to play_selected_channel function
- result_text.bind("<Double-1>", play_selected_channel)
- # Add button to check links
- check_button = tk.Button(app, text="Check Links", command=check_links, bg="#008000", fg="white")
- check_button.pack(side=tk.RIGHT, padx=5)
- # Add button to save working links
- save_button = tk.Button(app, text="Save Working Links", command=save_working_links, bg="#FF0000", fg="white")
- save_button.pack(side=tk.LEFT, padx=5)
- # Dropdown menu for channel categories
- category_urls = {
- "ALL-CATEGORY": "",
- "Animation": "https://iptv-org.github.io/iptv/categories/animation.m3u",
- "Auto": "https://iptv-org.github.io/iptv/categories/auto.m3u",
- "Business": "https://iptv-org.github.io/iptv/categories/business.m3u",
- "Classic": "https://iptv-org.github.io/iptv/categories/classic.m3u",
- "Comedy": "https://iptv-org.github.io/iptv/categories/comedy.m3u",
- "Cooking": "https://iptv-org.github.io/iptv/categories/cooking.m3u",
- "Culture": "https://iptv-org.github.io/iptv/categories/culture.m3u",
- "Documentary": "https://iptv-org.github.io/iptv/categories/documentary.m3u",
- "Education": "https://iptv-org.github.io/iptv/categories/education.m3u",
- "Entertainment": "https://iptv-org.github.io/iptv/categories/entertainment.m3u",
- "Family": "https://iptv-org.github.io/iptv/categories/family.m3u",
- "General": "https://iptv-org.github.io/iptv/categories/general.m3u",
- "Kids": "https://iptv-org.github.io/iptv/categories/kids.m3u",
- "Legislative": "https://iptv-org.github.io/iptv/categories/legislative.m3u",
- "Lifestyle": "https://iptv-org.github.io/iptv/categories/lifestyle.m3u",
- "Movies": "https://iptv-org.github.io/iptv/categories/movies.m3u",
- "Music": "https://iptv-org.github.io/iptv/categories/music.m3u",
- "News": "https://iptv-org.github.io/iptv/categories/news.m3u",
- "Outdoor": "https://iptv-org.github.io/iptv/categories/outdoor.m3u",
- "Relax": "https://iptv-org.github.io/iptv/categories/relax.m3u",
- "Religious": "https://iptv-org.github.io/iptv/categories/religious.m3u",
- "Science": "https://iptv-org.github.io/iptv/categories/science.m3u",
- "Series": "https://iptv-org.github.io/iptv/categories/series.m3u",
- "Shop": "https://iptv-org.github.io/iptv/categories/shop.m3u",
- "Sports": "https://iptv-org.github.io/iptv/categories/sports.m3u",
- "Travel": "https://iptv-org.github.io/iptv/categories/travel.m3u",
- "Weather": "https://iptv-org.github.io/iptv/categories/weather.m3u",
- "XXX": "https://iptv-org.github.io/iptv/categories/xxx.m3u",
- "Undefined": "https://iptv-org.github.io/iptv/categories/undefined.m3u",
- # Add more categories here
- }
- ========================= START===========================
- import tkinter as tk
- window = tk.Tk()
- greeting = tk.Label(text="Hello, Tkinter")
- greeting.pack()
- label = tk.Label(text="Hello, Tkinter")
- label = tk.Label(
- text="Hello, Tkinter",
- foreground="white", # Set the text color to white
- background="black" # Set the background color to black
- )
- "red"
- "orange"
- "yellow"
- "green"
- "blue"
- "purple"
- label = tk.Label(text="Hello, Tkinter", background="#34A2FE")
- label = tk.Label(text="Hello, Tkinter", fg="white", bg="black")
- label = tk.Label(
- text="Hello, Tkinter",
- fg="white",
- bg="black",
- width=10,
- height=10
- )
- button = tk.Button(
- text="Click me!",
- width=25,
- height=5,
- bg="blue",
- fg="yellow",
- )
- entry = tk.Entry(fg="yellow", bg="blue", width=50)
- import tkinter as tk
- window = tk.Tk()
- label = tk.Label(text="Name")
- entry = tk.Entry()
- label.pack()
- entry.pack()
- name = entry.get()
- name
- 'Real Python'
- entry.delete(0)
- entry.delete(0, tk.END)
- entry.insert(0, "Python")
- entry.insert(0, "Real ")
- window.destroy()
- window = tk.Tk()
- text_box = tk.Text()
- text_box.pack()
- text_box.get()
- Traceback (most recent call last):
- ...
- TypeError: get() missing 1 required positional argument: 'index1'
- text_box.get("1.0")
- text_box.get("1.0", "1.5")
- 'Hello'
- text_box.get("2.0", "2.5")
- 'World'
- text_box.get("1.0", tk.END)
- 'Hello\nWorld\n'
- text_box.delete("1.0", "1.4")
- text_box.get("1.0")
- '\n'
- text_box.delete("1.0")
- text_box.delete("1.0", tk.END)
- text_box.insert("1.0", "Hello")
- text_box.insert("2.0", "World")
- text_box.insert("2.0", "\nWorld")
- text_box.insert(tk.END, "Put me at the end!")
- text_box.insert(tk.END, "\nPut me on a new line!")
- -----------------------------------------------------------------------
- Assigning Widgets to Frames With Frame Widgets
- In this tutorial, you’re going to work with only five widgets:
- 1 Label
- 2 Button
- 3 Entry
- 4 Text
- 5 Frame
- These are the four you’ve seen so far plus the Frame widget.
- Frame widgets are important for organizing the layout of your widgets in an application.
- --------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame = tk.Frame()
- frame.pack()
- window.mainloop()
- -------------------------------------
- frame = tk.Frame()
- label = tk.Label(master=frame)
- ----------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame_a = tk.Frame()
- frame_b = tk.Frame()
- label_a = tk.Label(master=frame_a, text="I'm in Frame A")
- label_a.pack()
- label_b = tk.Label(master=frame_b, text="I'm in Frame B")
- label_b.pack()
- frame_a.pack()
- frame_b.pack()
- window.mainloop()
- --------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame_a = tk.Frame()
- label_a = tk.Label(master=frame_a, text="I'm in Frame A")
- label_a.pack()
- frame_b = tk.Frame()
- label_b = tk.Label(master=frame_b, text="I'm in Frame B")
- label_b.pack()
- # Swap the order of `frame_a` and `frame_b`
- frame_b.pack()
- frame_a.pack()
- window.mainloop()
- ---------------------------------------
- Adjusting Frame Appearance With Reliefs
- Frame widgets can be configured with a relief attribute that creates a border around the frame.
- You can set relief to be any of the following values:
- 1 tk.FLAT: Has no border effect (the default value)
- 2 tk.SUNKEN: Creates a sunken effect
- 3 tk.RAISED: Creates a raised effect
- 4 tk.GROOVE: Creates a grooved border effect
- 5 tk.RIDGE: Creates a ridged effect
- To apply the border effect, you must set the borderwidth attribute to a value
- ------------------------------------------------------------------------------------
- import tkinter as tk
- border_effects = {
- "flat": tk.FLAT,
- "sunken": tk.SUNKEN,
- "raised": tk.RAISED,
- "groove": tk.GROOVE,
- "ridge": tk.RIDGE,
- }
- window = tk.Tk()
- for relief_name, relief in border_effects.items():
- frame = tk.Frame(master=window, relief=relief, borderwidth=5)
- frame.pack(side=tk.LEFT)
- label = tk.Label(master=frame, text=relief_name)
- label.pack()
- window.mainloop()
- --------------------------------------
- tk.Label(text="Hello, Tkinter").pack()
- --------------------------------------------------
- Widget Class Variable Name Prefix Example
- Label lbl lbl_name
- Button btn btn_submit
- Entry ent ent_age
- Text txt txt_notes
- Frame frm frm_address
- ----------------------------------------------------------------------------------------
- 1 .place()
- 2 .grid()
- -----------------------------
- The .pack() Geometry Manager
- -----------------------------
- import tkinter as tk
- window = tk.Tk()
- frame1 = tk.Frame(master=window, width=100, height=100, bg="red")
- frame1.pack()
- frame2 = tk.Frame(master=window, width=50, height=50, bg="yellow")
- frame2.pack()
- frame3 = tk.Frame(master=window, width=25, height=25, bg="blue")
- frame3.pack()
- window.mainloop()
- --------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame1 = tk.Frame(master=window, height=100, bg="red")
- frame1.pack(fill=tk.X)
- frame2 = tk.Frame(master=window, height=50, bg="yellow")
- frame2.pack(fill=tk.X)
- frame3 = tk.Frame(master=window, height=25, bg="blue")
- frame3.pack(fill=tk.X)
- window.mainloop()
- -----------------------------------------------------------------------
- 1 tk.TOP
- 2 tk.BOTTOM
- 3 tk.LEFT
- 4 tk.RIGHT
- -------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame1 = tk.Frame(master=window, width=200, height=100, bg="red")
- frame1.pack(fill=tk.Y, side=tk.LEFT)
- frame2 = tk.Frame(master=window, width=100, bg="yellow")
- frame2.pack(fill=tk.Y, side=tk.LEFT)
- frame3 = tk.Frame(master=window, width=50, bg="blue")
- frame3.pack(fill=tk.Y, side=tk.LEFT)
- window.mainloop()
- ------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame1 = tk.Frame(master=window, width=200, height=100, bg="red")
- frame1.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
- frame2 = tk.Frame(master=window, width=100, bg="yellow")
- frame2.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
- frame3 = tk.Frame(master=window, width=50, bg="blue")
- frame3.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
- window.mainloop()
- ----------------------------------------------------------------------------
- The .place() Geometry Manager
- -------------------------------------
- import tkinter as tk
- window = tk.Tk()
- frame = tk.Frame(master=window, width=150, height=150)
- frame.pack()
- label1 = tk.Label(master=frame, text="I'm at (0, 0)", bg="red")
- label1.place(x=0, y=0)
- label2 = tk.Label(master=frame, text="I'm at (75, 75)", bg="yellow")
- label2.place(x=75, y=75)
- window.mainloop()
- ---------------------------------------------------------------
- The .grid() Geometry Manager
- ---------------------------------------
- import tkinter as tk
- window = tk.Tk()
- for i in range(3):
- for j in range(3):
- frame = tk.Frame(
- master=window,
- relief=tk.RAISED,
- borderwidth=1
- )
- frame.grid(row=i, column=j)
- label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")
- label.pack()
- window.mainloop()
- -------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- for i in range(3):
- for j in range(3):
- frame = tk.Frame(
- master=window,
- relief=tk.RAISED,
- borderwidth=1
- )
- frame.grid(row=i, column=j)
- label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")
- label.pack()
- window.mainloop()
- ------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- for i in range(3):
- for j in range(3):
- frame = tk.Frame(
- master=window,
- relief=tk.RAISED,
- borderwidth=1
- )
- frame.grid(row=i, column=j)
- label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")
- label.pack()
- window.mainloop()
- -------------------------------------------------------------------------
- 1 padx adds padding in the horizontal direction.
- 2 pady adds padding in the vertical direction.
- -----------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- for i in range(3):
- for j in range(3):
- frame = tk.Frame(
- master=window,
- relief=tk.RAISED,
- borderwidth=1
- )
- frame.grid(row=i, column=j, padx=5, pady=5)
- label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")
- label.pack()
- window.mainloop()
- ------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- for i in range(3):
- for j in range(3):
- frame = tk.Frame(
- master=window,
- relief=tk.RAISED,
- borderwidth=1
- )
- frame.grid(row=i, column=j, padx=5, pady=5)
- label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")
- label.pack(padx=5, pady=5)
- window.mainloop()
- ----------------------------------------------------------------------------
- 1 Index: The index of the grid column or row that you want to configure or a list
- of indices to configure multiple rows or columns at the same time
- 2 Weight: A keyword argument called weight that determines how the column or row
- should respond to window resizing, relative to the other columns and rows
- 3 Minimum Size: A keyword argument called minsize that sets the minimum size
- of the row height or column width in pixels
- ------------------------------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- for i in range(3):
- window.columnconfigure(i, weight=1, minsize=75)
- window.rowconfigure(i, weight=1, minsize=50)
- for j in range(0, 3):
- frame = tk.Frame(
- master=window,
- relief=tk.RAISED,
- borderwidth=1
- )
- frame.grid(row=i, column=j, padx=5, pady=5)
- label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")
- label.pack(padx=5, pady=5)
- window.mainloop()
- --------------------------------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- window.columnconfigure(0, minsize=250)
- window.rowconfigure([0, 1], minsize=100)
- label1 = tk.Label(text="A")
- label1.grid(row=0, column=0)
- label2 = tk.Label(text="B")
- label2.grid(row=1, column=0)
- window.mainloop()
- -----------------------------------------------------------------------------------------------------
- 1 "n" or "N" to align to the top-center part of the cell
- 2 "e" or "E" to align to the right-center side of the cell
- 3 "s" or "S" to align to the bottom-center part of the cell
- 4 "w" or "W" to align to the left-center side of the cell
- -----------------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- window.columnconfigure(0, minsize=250)
- window.rowconfigure([0, 1], minsize=100)
- label1 = tk.Label(text="A")
- label1.grid(row=0, column=0, sticky="n")
- label2 = tk.Label(text="B")
- label2.grid(row=1, column=0, sticky="n")
- window.mainloop()
- ------------------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- window.columnconfigure(0, minsize=250)
- window.rowconfigure([0, 1], minsize=100)
- label1 = tk.Label(text="A")
- label1.grid(row=0, column=0, sticky="ne")
- label2 = tk.Label(text="B")
- label2.grid(row=1, column=0, sticky="sw")
- window.mainloop()
- -------------------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- window.rowconfigure(0, minsize=50)
- window.columnconfigure([0, 1, 2, 3], minsize=50)
- label1 = tk.Label(text="1", bg="black", fg="white")
- label2 = tk.Label(text="2", bg="black", fg="white")
- label3 = tk.Label(text="3", bg="black", fg="white")
- label4 = tk.Label(text="4", bg="black", fg="white")
- label1.grid(row=0, column=0)
- label2.grid(row=0, column=1, sticky="ew")
- label3.grid(row=0, column=2, sticky="ns")
- label4.grid(row=0, column=3, sticky="nsew")
- window.mainloop()
- --------------------------------------------------------------------------------------
- .grid() .pack()
- sticky="ns" fill=tk.Y
- sticky="ew" fill=tk.X
- sticky="nsew" fill=tk.BOTH
- -----------------------------------------------------------------------------
- import tkinter as tk
- window = tk.Tk()
- window.title("Simple Text Editor")
- window.rowconfigure(0, minsize=800, weight=1)
- window.columnconfigure(1, minsize=800, weight=1)
- txt_edit = tk.Text(window)
- frm_buttons = tk.Frame(window, relief=tk.RAISED, bd=2)
- btn_open = tk.Button(frm_buttons, text="Open")
- btn_save = tk.Button(frm_buttons, text="Save As...")
- ---------------------------------------------------------------------------------------
- window = tk.Tk()
- window.title("Simple Text Editor")
- window.rowconfigure(0, minsize=800, weight=1)
- window.columnconfigure(1, minsize=800, weight=1)
- txt_edit = tk.Text(window)
- frm_buttons = tk.Frame(window, relief=tk.RAISED, bd=2)
- btn_open = tk.Button(frm_buttons, text="Open", command=open_file)
- btn_save = tk.Button(frm_buttons, text="Save As...", command=save_file)
- btn_open.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
- btn_save.grid(row=1, column=0, sticky="ew", padx=5)
- frm_buttons.grid(row=0, column=0, sticky="ns")
- txt_edit.grid(row=0, column=1, sticky="nsew")
- window.mainloop()
- --------------------------------------------------------------------------------
- import tkinter as tk
- def increase():
- value = int(lbl_value["text"])
- lbl_value["text"] = f"{value + 1}"
- def decrease():
- value = int(lbl_value["text"])
- lbl_value["text"] = f"{value - 1}"
- window = tk.Tk()
- window.rowconfigure(0, minsize=50, weight=1)
- window.columnconfigure([0, 1, 2], minsize=50, weight=1)
- btn_decrease = tk.Button(master=window, text="-", command=decrease)
- btn_decrease.grid(row=0, column=0, sticky="nsew")
- lbl_value = tk.Label(master=window, text="0")
- lbl_value.grid(row=0, column=1)
- btn_increase = tk.Button(master=window, text="+", command=increase)
- btn_increase.grid(row=0, column=2, sticky="nsew")
- window.mainloop()
- -----------------------------------------------------------------------------
- import random
- import tkinter as tk
- def roll():
- lbl_result["text"] = str(random.randint(1, 6))
- window = tk.Tk()
- window.columnconfigure(0, minsize=150)
- window.rowconfigure([0, 1], minsize=50)
- btn_roll = tk.Button(text="Roll", command=roll)
- lbl_result = tk.Label()
- btn_roll.grid(row=0, column=0, sticky="nsew")
- lbl_result.grid(row=1, column=0)
- window.mainloop()
- -------------------------------------------------------------------------------
- import tkinter as tk
- def fahrenheit_to_celsius():
- """Convert the value for Fahrenheit to Celsius and insert the
- result into lbl_result.
- """
- fahrenheit = ent_temperature.get()
- celsius = (5 / 9) * (float(fahrenheit) - 32)
- lbl_result["text"] = f"{round(celsius, 2)} \N{DEGREE CELSIUS}"
- # Set up the window
- window = tk.Tk()
- window.title("Temperature Converter")
- window.resizable(width=False, height=False)
- # Create the Fahrenheit entry frame with an Entry
- # widget and label in it
- frm_entry = tk.Frame(master=window)
- ent_temperature = tk.Entry(master=frm_entry, width=10)
- lbl_temp = tk.Label(master=frm_entry, text="\N{DEGREE FAHRENHEIT}")
- # Layout the temperature Entry and Label in frm_entry
- # using the .grid() geometry manager
- ent_temperature.grid(row=0, column=0, sticky="e")
- lbl_temp.grid(row=0, column=1, sticky="w")
- # Create the conversion Button and result display Label
- btn_convert = tk.Button(
- master=window,
- text="\N{RIGHTWARDS BLACK ARROW}",
- command=fahrenheit_to_celsius
- )
- lbl_result = tk.Label(master=window, text="\N{DEGREE CELSIUS}")
- # Set up the layout using the .grid() geometry manager
- frm_entry.grid(row=0, column=0, padx=10)
- btn_convert.grid(row=0, column=1, pady=10)
- lbl_result.grid(row=0, column=2, padx=10)
- # Run the application
- window.mainloop()
- ===========================END==========================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement