答案 0 :(得分:3)
from Tkinter import *
root = Tk()
root.title("Pantai Hospital")
# in main window I use only `pack`
l = Label(root, text="Welcome to Pantai Hospital!")
l.pack()
lf = LabelFrame(root, text="Specialist:")
lf.pack()
# inside LabelFrame I use only `grid`
t = Label(lf, text="Choose your specialist:")
t.grid(columnspan=2, stick='w')
specialistchoose = IntVar()
r1 = Radiobutton(lf, text="Cardiology", variable=specialistchoose, value=1)
r1.grid(row=1, column=0, stick='w')
r2 = Radiobutton(lf, text="Gastroenterology", variable=specialistchoose, value=2)
r2.grid(row=1, column=1, stick='w')
r3 = Radiobutton(lf, text="Dermatology", variable=specialistchoose, value=3)
r3.grid(row=1, column=2, stick='w')
r4 = Radiobutton(lf, text="Psychiatry", variable=specialistchoose, value=4)
r4.grid(row=2, column=0, stick='w')
r5 = Radiobutton(lf, text="Dentist", variable=specialistchoose, value=5)
r5.grid(row=2, column=1, stick='w')
root.mainloop()
仅返回true。使用Android.OS.Debug.IsDebuggerConnected
检测Mono / Xamarin Studio调试器的连接时间。
您可以使用以下步骤验证上述声明:
使用以下源代码创建一个名为 DebugTest 的新Xamarin.Android应用程序:
System.Diagnostics.Debugger.IsAttached
需要注意的一些重要事项:
[Activity (Name="com.companyname.debugtestapp.MainActivity", Label = "DebugTestApp", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button> (Resource.Id.myButton);
button.Click += delegate {
string androidConnected = Android.OS.Debug.IsDebuggerConnected ? "JDB Debugger" : "";
string monoConnected = System.Diagnostics.Debugger.IsAttached ? "Mono Debugger" : "";
button.Text = "Debugging mode: " + androidConnected + " | " + monoConnected;
};
}
}
覆盖活动的默认名称,因此它不使用程序集名称(Explained here)的MD5总和。通过Xamarin Studio开始调试应用程序。单击按钮以查看:
“调试模式:| Mono Debugger”
这意味着我们检测到 Mono 调试器。
杀死该应用。
通过以下一组终端命令将Java调试器连接到应用程序:
Name=com.companyname.debugtestapp.MainActivity
您应该看到:
# Start the main activity via adb. This will open it in debug mode, meaning it will wait until a debugger is connected before proceeding.
adb -d shell am start -D -n "com.companyname.debugtestapp/com.companyname.debugtestapp.MainActivity"
# Discover the Java Debugger port. Copy the number outputted here...
adb jdwp
# Forward the debugger port to JDB. Replace '7602' with the port number outputted by the command above.
adb forward tcp:8000 jdwp:7602
# Start the Java debugger...
jdb -attach 127.0.0.1:8000
这指定Java调试器已连接。
在手机上,单击按钮。您应该看到文本**调试模式:JDB调试器| **。