对于想了解如何在Tkinter计算器中仅显示一次逗号的读者,本文将提供新的信息,我们将详细介绍python的tkinter编写计算器,并且为您提供关于jquery–显示带有Cookie的模态仅显示一次
对于想了解如何在Tkinter计算器中仅显示一次逗号的读者,本文将提供新的信息,我们将详细介绍python的tkinter编写计算器,并且为您提供关于jquery – 显示带有Cookie的模态仅显示一次、JS图表在php循环中仅显示一次、linechart – 如何在折线图中仅显示一个数据点的值、linux – 如何在tail -f中仅显示新记录的内容?的有价值信息。
本文目录一览:- 如何在Tkinter计算器中仅显示一次逗号(python的tkinter编写计算器)
- jquery – 显示带有Cookie的模态仅显示一次
- JS图表在php循环中仅显示一次
- linechart – 如何在折线图中仅显示一个数据点的值
- linux – 如何在tail -f中仅显示新记录的内容?
如何在Tkinter计算器中仅显示一次逗号(python的tkinter编写计算器)
尝试使用if语句代替
input = e.get()
try:
input.index(".")
except:
e.insert(END,".")
,
我认为这是您要寻找的:
from tkinter import*
from tkinter.ttk import *
root = Tk()
def correct(inp):
if inp == '':
return True
if ' ' in inp:
return False
try:
float(inp)
except ValueError: #catching error because strings cannot be converted to string
return False
else:
return True
reg = root.register(correct) #registering validation
e = Entry(root,width=30,justify="right",font=(None,20),validate='key',validatecommand=(reg,'%P')) #assigning it while declaring
e.grid(row=0,column=0,columnspan=3,ipady=10,sticky=W)
#but19 = Button(root,text=".",,command=correct)
# but19.grid(row=5,column=3,ipadx=10,ipady=15)
root.mainloop()
这只是验证,您允许用户只输入小数,除此以外的任何其他内容都将不允许。
Take a look here for more info on validation
欢呼
,我认为您需要Button
小部件支持的称为“验证”的东西。通过单击from tkinter import*
from tkinter.ttk import *
PERIOD = '.'
root = Tk()
def insert_point():
if e.get().count(PERIOD) < 1: # Allow at most one in entry.
e.insert(END,PERIOD)
def check_okay(new_value):
return new_value.count(PERIOD) < 2 # Only zero or one allowed in entry.
ok_command = root.register(check_okay) # Register the callback function.
e = Entry(root,validate='all',validatecommand=(ok_command,'%P'))
e.grid(row=0,sticky=W)
but19 = Button(root,text=PERIOD,command=insert_point)
but19.grid(row=5,ipady=15)
root.mainloop()
或手动输入字符,可以确保输入的字符不超过一次(或您要执行的其他任何规则)。有关参考,请参见{{3 }}。
以下是您要尝试做的事情的方法:
const STR = 'Edges</label><div><div><div><imgsrc="img/tiles/light.png"></div><div><i>Carnival Pink: </i>7</div></div><div><div><imgsrc="img/tiles/light.png"></div><div><i>Chocolate Brown: </i>5</div></div></div></div><div><hr><label>'
const res = STR.match(/(?<=<i>)[^:]*/g)
console.log(res)
jquery – 显示带有Cookie的模态仅显示一次
$(document).ready(function() { $('#myModal').reveal(); });
我怎么可以修改这个,我相信使用cookies(有另外一种方式吗?),这样一来,只能在一周内为用户弹出一次,
解决方法
在显示模态之前检查cookie.如果有,请不要显示.如果不是,请存储一个新的cookie并显示模态.
$(document).ready(function() { if ($.cookie('modal_shown') == null) { $.cookie('modal_shown','yes',{ expires: 7,path: '/' }); $('#myModal').reveal(); } });
JS图表在php循环中仅显示一次
这是因为,您使用相同的ID(即id="my-chart"
,
和ID对于每个标签都是唯一的。如果您要为每个用户呈现图表,请尝试使用 class 而不是 id 定位它,或者可以为每个用户生成唯一ID,例如
<div id="my-chart-<?php echo $row['id']; ?>"></div>
,然后通过唯一ID定位它们。
linechart – 如何在折线图中仅显示一个数据点的值
当我们将鼠标悬停在该数据集点而不是所有数据集点上时,如何仅显示一个数据集点的值
解决方法
Working example JSFiddle
linux – 如何在tail -f中仅显示新记录的内容?
解决方法
tail -n 0 -f /var/log/syslog
男人的尾巴:
-n,--lines=K output the last K lines,instead of the last 10; or use -n +K to output lines starting with the Kth
关于如何在Tkinter计算器中仅显示一次逗号和python的tkinter编写计算器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于jquery – 显示带有Cookie的模态仅显示一次、JS图表在php循环中仅显示一次、linechart – 如何在折线图中仅显示一个数据点的值、linux – 如何在tail -f中仅显示新记录的内容?等相关知识的信息别忘了在本站进行查找喔。
本文标签: