简体   繁体   English

我想使用 python 在新的 tkinter 窗口中打印我的所有 excel 数据

[英]I want to print my all excel data in new tkinter window using python

我想在新的 tkinter 窗口中打印 excel 数据中存在的所有信息

You can use Tkinter's grid.您可以使用 Tkinter 的网格。 For example, to create a simple excel-like table:例如,要创建一个简单的类似 excel 的表格:

from Tkinter import *

root = Tk()

height = 5
width = 5
for i in range(height): #Rows
    for j in range(width): #Columns
        b = Entry(root, text="")
        b.grid(row=i, column=j)

mainloop()

To print, consider the following example in which I make a button with Tkinter that gets some text from a widget and then prints it to console using the print() function.要打印,请考虑以下示例,其中我使用 Tkinter 制作了一个按钮,该按钮从小部件获取一些文本,然后使用 print() 函数将其打印到控制台。

from tkinter import *
from tkinter import ttk

def print_text(*args):
    try:
        print(text1.get())
    except ValueError:
        pass

root = Tk()
root.title("Little tkinter app for printing")

mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column = 0, row = 0, sticky = (N,W,E,S))

mainframe.columnconfigure(0, weight = 1)
mainframe.rowconfigure(0, weight = 1)

text1 = StringVar()
text_entry = ttk.Entry(mainframe, width = 20, textvariable=text1)
text_entry.grid(column = 1, row = 2, sticky = (N,W,E,S))

ttk.Button(mainframe, text = "Print!", command =
           print_text(text1)).grid(column = 1, row = 3, sticky = (E))

for child in mainframe.winfo_children():
    child.grid_configure(padx = 5, pady = 5)

text_entry.focus()
root.bind('<Return>', print_text)

root.mainloop()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想用“%”号显示我的EXCEL数据。 我如何使用python做到这一点 - I want to display my EXCEL data with “%” sign. How can i do so by using python 想使用 python 在 excel 中打印一系列字符串 - want to print a series of string in excel using python 我是python的新手,我想使用python计算excel中列的字符串 - I am new to python and i want to calculate the string of the column in excel using python 我想使用java在excel中打印计数总数 - I want to print total number of count with exception in excel using java 我想使用过滤条件从 excel 中检索数据,如果过滤条件匹配,那么数据应该在 python 中迭代吗? - I want to retrieve the data from excel using filter criteria if filter matches then data should be iterated in python? 我想将特定列保存到 python 中的新 excel 表中 - i want to save a particular column into a new excel sheet in python 我想从组合框中获取 select 数据并使用 VBA Excel 中的 IF 语句将其拉到我的按钮 - I want to select data from a combo box and pull it through to my button using an IF statement in VBA Excel 我想将单元格数组中的数据导出到Excel文件中,并尽可能整洁,而没有用于新行的分号 - I want to export my Data in a Cell Array to an Excel file, as tidy as possible, without semi-colons for new rows 如何在 Excel 中使用 VBA 打印所有工作表? 我的代码的行为不像我认为的那样 - How do I print all sheets using VBA in Excel? My code doesn't behave like I think it should 我想在Excel文件中查找以在所有工作表的Excel文件中添加新行 - I want to do look up on excel file to add new row in excel file in all sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM