我需要打开和关闭显示器,当显示器打开时,我需要它来显示使用tkinter-python创建的欢迎消息。
我写的草图确实打开和关闭了显示器,但只有在我退出程序时才会显示tkinter标签。
谁能给我解释一下为什么在编辑草图的时候没有显示tkinter标签?
import sys
import os
import time
from tkinter import *
import tkinter as tk
from tkinter.font import Font
import RPi.GPIO as GPIO
#pin description
sensor = 11
GPIO.setwar
看一看这段代码,它恰好无缘无故地添加了另一个标签。
import tkinter
from tkinter import *
clicks = 1
def click_count():
global clicks
# making the label that shows how many idk you have
label = Label(frame, text="you have " + str(clicks), font=(('Courrier'), 32))
label.pack()
clicks += 1
我目前正在尝试建立一个探路者角色创建者,但遇到了障碍。我有多个Tab,使用ttk.notebook,设置在单独的文件和一个全局变量文件中。我正在尝试根据global_variable.py文件中的全局变量str_mod在Skill_Tab.py中更新self.acroMod_Label,该文件通过使用来自Stats_Tab.py的数据进行了修改。
main.py
from tkinter import *
from tkinter import ttk
from Stats_Tab import Stats_Tab
from Skills_Tab import Skills_Tab
#cre
在普通的Python 3.4中,如果你想在字符串中间打印一个变量,你可以这样做:
x = 31
print("The value of x is %s" % (x))
它将打印The value of x is 31。
在Tkinter中,如果你想让标签读取某个变量,你只需定义标签,如果标签的变量在任何时候发生变化,如果是Tkinter标签,标签就会自动更新。例如:
var = StringVar()
var.set("Label")
label = Label(main, text=var)
但是,如果我想让字符串的一部分成为Tkinter中的变量...
it
我正在尝试使用Tkinter创建一个Python。我首先创建一个窗口,以按钮的形式向用户显示选项。单击按钮时,我调用一个函数来创建一个带有Toplevel()函数的新窗口。在新的窗口里,我有一个按钮和一个标签。通过单击按钮,我希望更改标签的文本。然而,我得到了一个关于标签范围的错误。下面是代码概念的一个示例:
import tkinter as tk
# function called by popWin()
def func():
global win_lbl # declaring label as global so that I can edit its text
摘要:在Python中,当我从派生进程更新Tkinter label文本时,GUI上的标签不会被更新,尽管生成的进程被执行。如何使它从生成的过程中更新?
我正在Lubuntu 20.04中使用Python2.7.2
编辑:我也尝试了Python3.8,不得不额外安装python3-tk,更改一些语法(在print命令后插入括号,用Tkinter替换tkinter),但问题仍然相同。端编辑
下面是独立运行的示例代码:
from Tkinter import *
from multiprocessing import Process
# simple Label change invoked f
我要疯了,想通过StringVar更新这个标签。我在网上读了上百万的答案,看了很多教程,但在我运行程序的时候仍然无法得到它来更新标签。我遗漏了什么?
from os import name
import tkinter
import tkinter.filedialog as fd
from tkinter.constants import W
top = tkinter.Tk()
top.wm_title("NFT Generator")
L1 = tkinter.Label(top, text="Name your nft:")
L1.grid(row
因此,我试图构建一个简单的计算器,它在标签中显示数字pi,即3.14,每次单击'click me‘时,它会向3.14中添加另一个十进制值。例如,单击标签后,标签将显示3.141,第二次显示: 3.1415等等。
以下是代码:
# Import the Tkinter functions
from Tkinter import *
# Create a window
loan_window = Tk()
loan_window.geometry('{}x{}'.format(500, 100))
# Give the window a title
loan_win
因此,我正在Python中使用Tkinter创建一个简单的GUI。
现在,当用户将Roll Number (即主键)标签小部件保留为空并尝试插入数据时,我将插入None而不是空字符串,并且我希望抛出一个Error,而是用一个自动递增的滚动号值插入数据。我不希望主键被插入,如果滚动号标签小部件是空的.
这是我用来创建表的代码
c.execute("""
CREATE TABLE students(
enroll_no integer NOT NULL PRIMARY KEY,
first_name text NOT NULL,
midd
我正在开发一个python/tkinter标签小部件来更新它的内容。根据今天早些时候的一个线程,我遵循了如何将小部件组合在一起的说明。但是,在运行时,label小部件不会更改内容,而只是保留其原始内容。据我所知,从来没有调用过decrement_widget()。有什么想法吗?
def snooze (secs):
"""
Snoozes for the given number of seconds. During the snooze, a progress
dialog is launched notifying the
""
我试图使用枕头在Tkinter中显示一个图像,但我得到了一个奇怪的错误:“进程用退出代码-1073741819 (0xC0000005)完成”,而Tkinter窗口从未出现。
下面是代码(简化为最大值):
from PIL import Image, ImageTk
from tkinter import Tk
t = Tk()
i = Image.open('data/pic.jpg') # small picture (29kb, 100x100px)
i_tk = ImageTk.PhotoImage(i) # The problem disappears when t