我正在创建一个设置窗口,但无法弄清楚如何为单选按钮设置默认值。我希望窗口以选中的黑色开头,如果用户未单击任一按钮,则仍将返回“ B”值。谢谢您的帮助。
import tkinter
from tkinter import ttk
class Test:
def __init__(self):
self.root_window = tkinter.Tk()
#create who goes first variable
self.who_goes_first = tkinter.StringVar()
#black radio button
self._who_goes_first_radiobutton = ttk.Radiobutton(
self.root_window,
text = 'Black',
variable = self.who_goes_first,
value = 'B')
self._who_goes_first_radiobutton.grid(row=0, column=1)
#white radio button
self._who_goes_first_radiobutton = ttk.Radiobutton(
self.root_window,
text = 'White',
variable = self.who_goes_first,
value = 'W')
self._who_goes_first_radiobutton.grid(row=1, column=1)
def start(self) -> None:
self.root_window.mainloop()
if __name__ == '__main__':
game = Test()
game.start()
Run Code Online (Sandbox Code Playgroud) 我正在学习 lldb,我很好奇你如何为更大的数据结构(例如向量)设置观察点。我知道我可以使用打印并且可以工作,但我收到一条消息说不支持大小为“x”的观察点。有没有解决的办法?谢谢您的帮助!
(lldb) s
Process 36110 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x0000000100001600 a.out`main at test.cpp:10
7 vector<int> arr;
8 arr.push_back(1);
9 arr.push_back(2);
-> 10 arr.push_back(3);
11 arr.push_back(4);
12 arr.push_back(5);
13
Target 0: (a.out) stopped.
(lldb) print arr
(std::__1::vector<int, std::__1::allocator<int> >) $2 = size=2 {
[0] = 1
[1] = 2
}
(lldb) w s v arr
error: Watchpoint creation failed (addr=0x7ffeefbff458, size=24, variable expression='arr').
error: watch size of 24 is not …Run Code Online (Sandbox Code Playgroud) 如果您对多个值进行相同的比较,是否有一种速记方法可以在 if 语句中编写比较。只是好奇是否有可能发生这样的事情。谢谢您的帮助!
a =1
b =1
c =1
if a == 1 and b ==1 and c == 1:
print('yes')
# It would be nice if you could do this or something like it.
if a,b,c == 1:
print('this would be easier')
Run Code Online (Sandbox Code Playgroud) 我很好奇是否有办法使用vim一次用引号将多个单词引起来。我正在使用tpope环绕声并重复播放,但我想知道是否有类似的命令
3ysw"
Run Code Online (Sandbox Code Playgroud)
所以从
one two three
Run Code Online (Sandbox Code Playgroud)
至
"one" "two" "three"
Run Code Online (Sandbox Code Playgroud) c++ ×1
comparison ×1
if-statement ×1
lldb ×1
python ×1
python-3.x ×1
radio-button ×1
shortcut ×1
surround ×1
tkinter ×1
vector ×1
vim ×1
watchpoint ×1