def __init__(self, master, controller, title, artist, image, *args, **kwargs): tk.Frame.__init__(self, master, *args, **kwargs) self['bg'] = '#2c2c2c' self.title = title self.image = image self.artist = artist self.upper = tk.Frame(self, bg='#2c2c2c') self.lower = tk.Frame(self, bg='#2c2c2c') self.pause_icon2 = self.prepare_image('pause_icon2.png', 30) self.play_icon2 = self.prepare_image('play_icon2.png', 30) self.repeat_icon = self.prepare_image('repeat_icon.png', 15) self.repeat_active_icon = self.prepare_image('repeat_active.png', 15) self.previous_icon = self.prepare_image('previous.png', 18) self.next_icon = self.prepare_image('next.png', 18) self.shuffle_icon = self.prepare_image('shuffle.png', 15) self.shuffle_active_icon = self.prepare_image('shuffle_active.png', 15) self.pause_icon3 = self.prepare_image('pause_icon2.png', 32) self.play_icon3 = self.prepare_image('play_icon2.png', 32) if Middle.single: self.current_repeat_icon = self.repeat_active_icon else: self.current_repeat_icon = self.repeat_icon if Middle.shuffle: self.current_shuffle_icon = self.shuffle_active_icon else: self.current_shuffle_icon = self.shuffle_icon # ------------------------------------------------------ style = ThemedStyle(self) custom_name = 'custom' + str(Middle.count) + '.Horizontal.Scale' self.trough = Image.open('images/green_trough.png') self.trough = self.trough.resize((8, 4), Image.ANTIALIAS) self.trough = ImageTk.PhotoImage(self.trough) self.circle = Image.open('images/circle.png') self.circle = self.circle.resize((20, 20), Image.ANTIALIAS) self.circle = ImageTk.PhotoImage(self.circle) style.element_create(custom_name + '.trough', 'image', self.trough) style.element_create(custom_name + '.slider', 'image', self.circle) style.layout('custom.Horizontal.TScale', [(custom_name + '.trough', {'sticky': 'ew'}), (custom_name + '.slider', {'side': 'left', 'sticky': '', 'children': [('Horizontal.Scale.label', {'sticky': ''})] })]) style.theme_settings("vista", { "custom.Horizontal.TScale": { 'map': {'background': [("active", "#2c2c2c"), ("!disabled", "#2c2c2c")], } }}) # ------------------------------------------------------ self.controller = controller self.playing = True self.button = tk.Button(self.upper, image=self.play_icon2, background='#2c2c2c', activebackground='#2c2c2c', bd=0, relief=tk.FLAT, command=self.click, width=33, height=33) self.repeat = tk.Button(self.upper, image=self.current_repeat_icon, background='#2c2c2c', activebackground='#2c2c2c', bd=0, relief=tk.FLAT, width=15, height=15, command=self.on_repeat) self.shuffle = tk.Button(self.upper, image=self.current_shuffle_icon, background='#2c2c2c', activebackground='#2c2c2c', bd=0, relief=tk.FLAT, width=15, height=15, command=self.on_shuffle) self.next = tk.Button(self.upper, image=self.next_icon, background='#2c2c2c', activebackground='#2c2c2c', bd=0, relief=tk.FLAT, width=18, height=18, command=self.play_next) self.previous = tk.Button(self.upper, image=self.previous_icon, background='#2c2c2c', activebackground='#2c2c2c', bd=0, relief=tk.FLAT, width=18, height=18, command=self.play_previous) from Base.listOfPage import currentTrack self.sliderValue = tk.DoubleVar() self.slider = ttk.Scale(self.lower, to=currentTrack[0]['instance'].songDuration, orient=tk.HORIZONTAL, length=700, variable=self.sliderValue, command=self.UpdateSlider, style='custom.Horizontal.TScale') self.currentTime = tk.Label(self.lower, text="--/--", foreground='#999999', background='#2c2c2c') endTime = self.convertTime(currentTrack[0]['instance'].songDuration) self.endTime = tk.Label(self.lower, text=endTime, foreground='#999999', background='#2c2c2c') self.shuffle.grid(row=0, column=1, padx=12) self.previous.grid(row=0, column=2, padx=12) self.button.grid(row=0, column=3, padx=12) self.next.grid(row=0, column=4, padx=12) self.repeat.grid(row=0, column=5, padx=12) self.currentTime.grid(row=0, column=0, sticky='nsew') self.slider.grid(row=0, column=1, sticky='nsew') self.endTime.grid(row=0, column=2, sticky='nsew') self.upper.grid(row=0, column=0, pady=(5, 0)) self.lower.grid(row=1, column=0, sticky='nsew', pady=(0, 10)) # self.upper.grid_columnconfigure((0, 1, 2, 3, 4, 5), weight=1) self.upper.grid_rowconfigure(0, weight=1) # self.upper.grid_propagate(False) self.lower.grid_columnconfigure((0, 2), weight=1) self.lower.grid_columnconfigure(1, weight=10) self.lower.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure((0, 1), weight=1) self.button.bind('<Enter>', self.enter) self.button.bind('<Leave>', self.leave) Middle.count += 1
def __init__(self, master, *args, **kwargs): tk.Frame.__init__(self, master, *args, **kwargs) self['bg'] = '#2c2c2c' self['width'] = 300 style = ThemedStyle(self) custom_name = 'custom' + str(Right.count) + '.Horizontal.Scale' self.trough = Image.open('images/green_trough.png') self.trough = self.trough.resize((8, 4), Image.ANTIALIAS) self.trough = ImageTk.PhotoImage(self.trough) self.circle = Image.open('images/circle.png') self.circle = self.circle.resize((20, 20), Image.ANTIALIAS) self.circle = ImageTk.PhotoImage(self.circle) style.element_create(custom_name+'.trough', 'image', self.trough) style.element_create(custom_name + '.slider', 'image', self.circle) style.layout('custom.Horizontal.TScale', [(custom_name+'.trough', {'sticky': 'ew'}), (custom_name+'.slider', {'side': 'left', 'sticky': '', 'children': [('Horizontal.Scale.label', {'sticky': ''})] })]) style.theme_settings("vista", { "custom.Horizontal.TScale": { 'map': {'background': [("active", "#2c2c2c"), ("!disabled", "#2c2c2c")], } }}) self.volume_icon = self.prepare_image('volume_icon2.png', 20) self.mute_icon = self.prepare_image('mute_icon.png', 20) self.volume_button = tk.Button(self, image=self.volume_icon, background='#2c2c2c', activebackground='#2c2c2c', bd=0, relief=tk.FLAT, width=20, height=20, padx=0, pady=0, command=self.click ) self.volume_button.grid(row=0, column=1, padx=(0, 2)) self.volume = tk.DoubleVar() self.volume.set(70) self.volumeSlider = ttk.Scale(self, to=100, orient=tk.HORIZONTAL, length=1, variable=self.volume, command=self.UpdateVolume, style='custom.Horizontal.TScale') self.volumeSlider.grid(row=0, column=2, sticky='nsew', padx=(0, 15)) self.grid_columnconfigure(0, weight=3) self.grid_columnconfigure(2, weight=1) self.grid_rowconfigure(0, weight=1) self.grid_propagate(False) Right.count += 1