我使用从打印到热敏爱普生T82打印机的代码,但当我用tkinter和mainloop() python修改它时,在关闭布局GUI之前,不会直接打印出数据。我希望这个脚本可以打印出我的数据,而不需要我关闭布局GUI。
这是我的密码:
import subprocess
from Tkinter import *
class tes_print:
def __init__(self):
self.printData()
def printData(self):
data = " MY TEXT "
lpr = subproc
我在Python3.x中使用Tkinter制作一个按钮,将布尔变量的值从true更改为false,然后使用if语句检查该值是否为false。下面是我的代码:
import tkinter
import time
x = True
top = tkinter.Tk()
def helloCallBack():
x = False
print (x)
B = tkinter.Button(top, text ="Hello", command = helloCallBack)
B.pack()
if x == False:
print ('Hel
我试图使用Tkinter中的GUI按钮,但在尝试使用它们时遇到了问题。这段代码应该(至少我期望它会)生成几个按钮,当单击这些按钮时,会打印出所显示的字母。但是,无论按下哪个按钮,它都会打印出最后生成的按钮的结果。像这样的函数有没有不同的使用方式?
import tkinter
win = tkinter.Tk()
players = ["A","B","C","D"]
for p in players:
playerBtn = tkinter.Button(win,text=p,command=lambda : p
我刚开始使用Tkinter在python中创建GUI。我在堆栈溢出中找到了一个脚本,它提供了一个GUI,我可以在其中手动添加数据。我尝试动态地添加数据,从而使用以下代码实现整个过程的自动化:
def insert_data(self):
"""
Insertion method.
"""
for l in range(10):
time.sleep(3)
print(i)
我可能在这里问些蠢事。现在我要进口这些:
import os
from datetime import datetime
from time import sleep
import cv2
import numpy as np
import mediapipe as mp
import math
import sys
import tkinter
import customtkinter
from tkinter import filedialog
from PIL import ImageTk, Image
import PIL.Image
import ctypes
import requ
我有接受用户输入的python代码,因此我使用了大量的input语句。现在,我正在使用Tkinter创建GUI,并希望在Tkinter中显示这些输入语句。有没有办法到那里去呢?
对于ex。
var=float(input("enter a number"))
现在我想显示输入语句"enter a number in Tkinter“。有可能做到吗?如果是,是如何实现的?
编辑:让我包含我的代码,这样我就可以获得一些特定的帮助。
import Tkinter
def goPush():
win2=Tkinter.Toplevel()
win2.geometry('400x50')
Tkinter.Label(win2,text="If you have prepared as Help describes select Go otherwise select Go Back").pack()
Tkinter.Button(win2,text="Go",command=bounceP
到目前为止,我的代码是:
import tkinter
def hello():
a = tkinter.Button(text ="what is this", padx = 10, pady = 10)
a.pack()
c = tkinter.Button(text ="what do you want", padx = 10, pady = 10)
c.pack()
b = tkinter.Button(text = "Welcome to the interface. click to get started
我试图在一个目录中打开几个excel文件夹,然后能够处理这些数据(比如对三个文件取一行的平均值)。我现在的主要目标是能够在每个excel文件中显示信息。我使用了下面的代码来做到这一点。但是当我显示它时,它会将'0‘元素输出到'29’element...then,它跳过30-50,然后打印出51-80。
下面是我在python上输出的一个片段:
import numpy as np
import scipy.io as sio
import scipy
import matplotlib.pyplot as plt
import os
import pandas as p
这是我的程序,我打包了我的小部件,所以它会留在左边,但不知何故,当我运行它时,小部件不会从左边出现。人物和颜色出现在中间,而可怕的人物和生物出现在左边。我希望人和颜色的小工具也出现在左边。
这是我的程序
from Tkinter import *
import Tkinter
import tkMessageBox
class StoryMaker:
def __init__(self):
# Create the main window.
self.main_window = Tkinter.Tk()
#Create nine frames to group widg
这里我有一个列表,它是我从MYSQL连接器的游标中获得的。我在获取数据时没有问题。但我对使用tkinter的OptionMenu功能制作菜单很感兴趣,我收到的数据。这就是我正在尝试的 from tkinter import *
r = Tk()
name_ = StringVar()
name = [('John',),('Jimmy',),('Smith',),('Rosel',)]
#Here I am directly giving the list, but this the output which I g