Skip to content

Instantly share code, notes, and snippets.

@SZRabinowitz
Last active January 24, 2025 05:26
Show Gist options
  • Save SZRabinowitz/7becbf2ca92a09de58639d8bdfc251f6 to your computer and use it in GitHub Desktop.
Save SZRabinowitz/7becbf2ca92a09de58639d8bdfc251f6 to your computer and use it in GitHub Desktop.
import TermTk as ttk
root = ttk.TTk(layout=ttk.TTkVBoxLayout())
input = ttk.TTkLineEdit(inputType=ttk.TTkLineEdit.EchoMode.Password, parent=root)
# Should use password mode, but its using int mode
# Not sure if I am doing it wrong or if its a bug
root.mainloop()
import shutil
root = ttk.TTk()
frame = ttk.TTkFrame(size=shutil.get_terminal_size())
vbox = ttk.TTkVBoxLayout(size=(50, 10))
row_1 = ttk.TTkHBoxLayout()
row_1.addWidget(ttk.TTkLabel(text=(_ := "Admin Key: "), maxWidth=len(_)))
row_1.addWidget(ttk.TTkLineEdit(inputType=ttk.TTkK.Input_Password))
row_2 = ttk.TTkHBoxLayout()
row_2.addWidget(ttk.TTkButton(text="Submit", maxWidth=10))
# uncomment the line below to fix the issue. Why does it behave like this?
# row_2.addWidget(ttk.TTkSpacer()) # necessary else the input disappears. ???
vbox.addItems([row_1, row_2])
frame.addWidget(vbox)
root.addWidget(frame)
root.mainloop()
import shutil
root = ttk.TTk()
frame = ttk.TTkFrame(size=shutil.get_terminal_size())
vbox = ttk.TTkVBoxLayout(size=(50, 10))
row_1 = ttk.TTkHBoxLayout()
row_1.addWidget(ttk.TTkLabel(text=(_ := "Admin Key: "), maxWidth=len(_)))
row_1.addWidget(ttk.TTkLineEdit(inputType=ttk.TTkK.Input_Password))
row_2 = ttk.TTkHBoxLayout()
row_2.addWidget(ttk.TTkButton(text="Submit", maxWidth=10))
# uncomment the line below to fix the issue. Why does it behave like this?
row_2.addWidget(ttk.TTkSpacer()) # necessary else the input disappears. ???
vbox.addItems([row_1, row_2])
frame.addWidget(vbox)
root.addWidget(frame)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment