Я разработал простое приложение, используя Tkinter, python 3.7.4 и на Mac OS Mojave 10.14.6.Я выполнил тот же код на Ubuntu 18.04 и последней Windows 10, и приложение выглядит нативно.Однако, когда я запускаю его на своем Macbook, он не выглядит нативным, как другие приложения Mac GUI.
Например, посмотрите на этот снимок экрана:
Обратите внимание на серый фон наwidgets.
Вот код для этого:
import datetime
import gettext
import sys
import time
import os
import tkinter
import tkinter.ttk as ttk
from tkinter.filedialog import askopenfilename
from tkinter import *
from tkinter import filedialog
# All translations provided for illustrative purposes only.
# english
_ = lambda s: s
class MainFrame(ttk.Frame):
"Main area of user interface content."
def __init__(self, parent):
ttk.Frame.__init__(self, parent)
self.parent = parent
paddings = {'padx': 6, 'pady': 6}
self.download_location = '/'.join(os.getcwd().split('/')[:3]) + '/Downloads'
ttk.Label(parent, text="Youtube Url").pack(side='top', anchor='w', **paddings)
self.entry = ttk.Entry(parent, )
self.entry.pack(side='top', fill='x', **paddings)
# todo delete this line
self.entry.insert(0, 'https://www.youtube.com/watch?v=nXait2wHOQc')
self.button = ttk.Button(parent, text="Download", command=self.do_download)
self.button.pack(side='top', **paddings, anchor='w')
# style = ttk.Style()
# style.configure('TButton', foreground="red")
# self.button.config(style='Alarm.TButton')
self.location_button = ttk.Button(parent, text="Location", command=self.browse_button)
self.location_button.pack(side='top', **paddings, anchor='w')
self.statusStringVar = StringVar()
self.statusStringVar.set('status here')
self.status = ttk.Label(parent, textvariable=self.statusStringVar, text='status', )
self.status.pack(side='top', anchor='w', fill='x', **paddings)
self.locStringVar = StringVar()
self.locStringVar.set(f"Location: {self.download_location}")
self.locationLabel = ttk.Label(parent, textvariable=self.locStringVar, )
self.locationLabel.pack(side='top', anchor='w', fill='x', **paddings)
self.mp3_check_value = StringVar()
self.mp3_checkbox = ttk.Checkbutton(parent, text='Convert to MP3')
self.mp3_checkbox.config(variable=self.mp3_check_value, onvalue='yes', offvalue='no')
self.mp3_check_value.set('yes')
self.mp3_checkbox.pack(side='top', anchor='w', **paddings)
self.progressIntVar = IntVar()
self.progressIntVar.set(0)
self.mpb = ttk.Progressbar(parent, orient="horizontal", length=200, mode="determinate")
self.mpb['variable'] = self.progressIntVar
self.mpb.pack(side='top', anchor='w', fill='x', **paddings)
self.mpb["maximum"] = 100
# self.mpb["value"] = 0
def do_download(self):
pass
def progress_hook(self, d):
pass
def browse_button(self):
filename = filedialog.askdirectory()
print(filename)
self.download_location = filename
self.locStringVar.set(f"Location: {self.download_location}")
class Application(tkinter.Tk):
"Create top-level Tkinter widget containing all other widgets."
def __init__(self):
tkinter.Tk.__init__(self)
self.wm_title('Tkinter YDL')
self.wm_geometry('640x480')
self.mainframe = MainFrame(self)
self.mainframe.pack(side='right', fill='y')
if __name__ == '__main__':
APPLICATION_GUI = Application()
APPLICATION_GUI.mainloop()
Я что-то здесь упускаю?Пожалуйста, помогите.