3

ボタンをクリックして押したままにしない限り、ボタンにテキストを表示しない機能するコードがあります。ボタンのテキストを離すと、再び空白になります。私は他のフォーラムでこれを解決しようとしましたが、

注意してください:コード自体に問題はありません。

私のラップトップがコードを実行する方法に何らかの問題があります。python3.7tcl-tkを再インストールしてみました。他に何をすべきか本当にわかりません。

4

3 に答える 3

4

この行を追加するソリューションは次のとおりfrom tkinter import ttkです。

ttk.ボタン、ラベル、エントリなどを使用する場所ならどこでも使用できます。

ttk .Button(text="ログイン", width="30", コマンド = ログイン).pack()

ここにコードがありますので、試してみてください。

def main_screen():
  from tkinter import ttk

  global screen
  screen = Tk()

  screen.geometry("500x500")
  screen.title("4rManager")

  Label(text="Login/Register", font=("Calibri", 13)).pack()
  ttk.Label(text="").pack()
  ttk.Button(text="Login").pack()
  ttk.Label(text="").pack()
  ttk.Button(text="Register").pack()

  screen.mainloop()

main_screen()

私が助けてくれることを願っています。

于 2019-03-14T23:24:25.863 に答える
0

Updating doesn't work for everyone, I've read several posts of those for whom it didn't, and it didn't for me.

But since resizing the window works, there must be something that the tk instance does when resizing that makes everything appear again.

So you might check what happens there, and use that if your program detects if the OS is Mojave. Obviously this is not production worthy and only a fix for your own local projects or maybe some course project, but at least it's something.

于 2018-12-18T14:23:51.680 に答える