虽然使用 simplesialog.askstring 很好,但我想调整弹出窗口的大小并调整文本输入的宽度。
(示例代码)
from tkinter import *
from tkinter import simpledialog
prompts = ["name", "age", "height", "wheight"]
root = Tk()
for p in prompts:
answer = simpledialog.askstring(p, root)
print(answer)
Run Code Online (Sandbox Code Playgroud)
我查看了不同的文档,但似乎无法找到如何做到这一点。
我有一个对话框,我在我的所有内部页面中使用它在主页上正常工作但是当第1页开始时我得到一个错误,表示未捕获的TypeError:无法读取未定义的属性'sdIntContent'并且对话框不再出现
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css">
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.min.css">
<script type="text/javascript" src="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog2.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.css">
<script type="text/javascript">//<![CDATA[
$(document).on('pageinit', '#home', function(){
$(document).on ('click','#firstbutton', function () {
$('#footerdialog').simpledialog2({themeDialog: 'c'});
});
$(document).on('click','#first',function () {
window.location.href = "#first";
$('#footerdialog').simpledialog2('close');
});
$(document).on('click','#second',function () {
window.location.href = "#second";
$('#footerdialog').simpledialog2('close');
});
});//]]>
</script>
<!--script type="text/javascript">//<![CDATA[
$(document).on('pageinit', '#home', function(){
$(document).on ('click','#secondbutton', function () {
$.mobile.changePage('#secondpage', {
transition: 'slideup',
changeHash: true,
role: 'dialog'
});
}); …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个弹出窗口,人们可以在其中填写输入框中的字符串。我已经经历了很多例子,但它不起作用。
我正在尝试这样做:
var_entry = simpledialog.askstring("Test", "Test")
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
_tkinter.TclError: window ".!_querystring" was deleted before its visibility changed
Run Code Online (Sandbox Code Playgroud)
提前致谢!
编辑:发布错误的错误消息
在下面的代码中,第一个对话框立即获得焦点,因此用户只需键入答案并按 Enter。在第二个中,在 Windows 中运行时似乎不会发生这种情况。运行 Raspbian 9,两个窗口在打开时都会获得焦点。
有什么办法可以让两个窗口在 Windows 中打开时都获得焦点?
import tkinter as tk
from tkinter import simpledialog
root = tk.Tk()
root.withdraw()
answer1 = simpledialog.askstring("Test1","This one gets focus when it opens",parent=root)
answer2 = simpledialog.askstring("Test2","This one doesn't",parent=root)
Run Code Online (Sandbox Code Playgroud) 我添加了SimpleDialog2 个选项:失物招领。每当我做出选择并被重定向到我想要的位置时,SimpleDialog 不会关闭并停留在我的屏幕上。
开关:
switch (
await showDialog(
context: context,
child: new SimpleDialog(
title: new Text("Which category?"),
children: <Widget>[
new SimpleDialogOption(child: new Text("Found"),
onPressed: () {
goToCreate();
},
),
new SimpleDialogOption(child: new Text("Lost"),
onPressed: () {
//Whatever
},
),
],
)
)
)
Run Code Online (Sandbox Code Playgroud)
和案例:
{
case "Found":
goToCreate();
break;
case "Lost":
//Whatever
break;
}
Run Code Online (Sandbox Code Playgroud) 在我的 Simpledialog 中向按下的方法添加快餐栏时,我遇到了下面的错误代码。[Scaffold.of() 在不包含 Scaffold 的上下文中调用。]
我想就如何提供正确的上下文来解决它寻求您的建议。
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(home: new AlertApp()));
}
class AlertApp extends StatefulWidget {
@override
_AlertAppState createState() => _AlertAppState();
}
class _AlertAppState extends State<AlertApp> {
SimpleDialog _simdalog;
void sDialog(){
_simdalog = new SimpleDialog(
title: new Text("Add To Shopping Cart"),
children: <Widget>[
new SimpleDialogOption(
child: new Text("Yes"),
onPressed: (){
final snackBar = SnackBar(content: Text('Purchase Successful'));
Scaffold.of(context).showSnackBar(snackBar);
},
),
new SimpleDialogOption(
child: new Text("Close"),
onPressed:() {Navigator.pop(context);},
),
],
);
showDialog(context: context, builder: (BuildContext context){ …Run Code Online (Sandbox Code Playgroud) 我正在使用颤振构建 android 应用程序。我在以编程方式关闭简单对话框时遇到问题。
现在我有一个名为 ListVessel 的有状态页面。此页面包含来自数组 otherVessels 的 listTile。
下面是这个页面的代码。
class ListVessel extends StatefulWidget {
final Function() notifyParent;
ListVessel({Key key, @required this.notifyParent}) : super(key: key);
@override
_ListVesselState createState() => _ListVesselState();
}
class _ListVesselState extends State<ListVessel> {
@override
Widget build(BuildContext context) {
return ListView.separated(
separatorBuilder: (context, index) => Divider(color: Colors.blueGrey),
itemCount: otherVessels.length,
itemBuilder: (context, index) {
return ListTile(
title: Text("Name: "+otherVessels[index]["shipName"]),
onTap: () {
showDialog (
context: context,
builder: (_){
return otherTap(idx:index);
}
);
}
);
},
);
}
}
} …Run Code Online (Sandbox Code Playgroud) simpledialog ×7
flutter ×3
tkinter ×3
android ×2
python ×2
javascript ×1
jquery ×1
navigator ×1
python-3.x ×1
showdialog ×1
snackbar ×1
string ×1