我需要一个单独的框架,与tkinter窗口上的Python空闲相同

问题描述 投票:-4回答:1

我做了很多尝试,将python idlw嵌入我的tkinter窗口。是否有任何预定义的模块要与tkinter窗口一起嵌入空闲状态?

# -*- coding: utf-8 -*-

## Front Homepage
from sklearn import linear_model
import matplotlib.pyplot as plt
from matplotlib import interactive
from login import *
from PIL import ImageTk, Image
import tkinter as tk
import os
from tkinter.ttk import *



##creating window
root = tk.Tk()

## Title bar of front page 
program_name="Silk Project : SUPERVISED MODEL"
root.title(program_name)

root.configure(bg = "Pink")


## Menu Bar
menu_bar=Menu(root)

## File menu in menu bar 
file_menu=Menu(menu_bar,tearoff=0)
menu_bar.add_cascade(label="File",menu=file_menu,underline=0)
file_menu.add_command(label="New",accelerator="Ctrl+N")
file_menu.add_command(label="Open",accelerator="Ctrl+O")
file_menu.add_command(label="Save",accelerator="Ctrl+S")
file_menu.add_command(label="Save as",accelerator="Shift+Ctrl+S")
file_menu.add_separator()
file_menu.add_command(label="Exit",accelerator="Alt+F4",)
root.config(menu=menu_bar)

## Edit menu in menu bar 
Edit_menu=Menu(menu_bar,tearoff=0)
menu_bar.add_cascade(label="Edit",menu=file_menu,underline=0)
Edit_menu.add_command(label="New",accelerator="Ctrl+N")
Edit_menu.add_command(label="Open",accelerator="Ctrl+O")
Edit_menu.add_command(label="Save",accelerator="Ctrl+S")
Edit_menu.add_command(label="Save as",accelerator="Shift+Ctrl+S")
Edit_menu.add_separator()
Edit_menu.add_command(label="Exit",accelerator="Alt+F4",)
root.config(menu=menu_bar)

## Option menu in menu bar 
Option_menu=Menu(menu_bar,tearoff=0)
menu_bar.add_cascade(label="Option",menu=file_menu,underline=0)
Option_menu.add_command(label="New",accelerator="Ctrl+N")
Option_menu.add_command(label="Open",accelerator="Ctrl+O")
Option_menu.add_command(label="Save",accelerator="Ctrl+S")
Option_menu.add_command(label="Save as",accelerator="Shift+Ctrl+S")
Option_menu.add_separator()
Option_menu.add_command(label="Exit",accelerator="Alt+F4",)
root.config(menu=menu_bar)



## FrAME A
s = Style()
s.configure('My.TFrame', background='plum1')
frame = Frame(root , style='My.TFrame')
frame.place(height=600, width=250, x=0, y=0)


## FrAME B
s1 = Style()
s1.configure('My2.TFrame', background='White')
frame2 = Frame(root , style='My2.TFrame')
frame2.place(height=590, width=950, x=250, y=15)

##Output Label 
var="Output"
label1 = tk.Label(root , borderwidth = 10 , text=var , background="orange")
label1.place(height =15 , width =50 ,x=250,y=0)



## Size of Homepage 
root.geometry("1200x600+50+25")
#not minimization and maximization property
root.resizable(0,0)


## Output Window :

from tkinter import *
from subprocess import *

print("Hello world")


def func():
    proc = Popen("run.py", stdout=PIPE, stdin=PIPE ,stderr=PIPE , shell=True)
    proc = proc.communicate()
    output.insert(END, proc)

Check = Button(frame, text="Display output", command=func)
Quit = Button(frame, text="Exit", fg="red", command=root.quit)
output = Text(frame2)

Check.pack()
Quit.pack()
output.place(height=590, width=950, x=0, y=0)



root.iconbitmap(r'C:\Users\Silk\Desktop\SILK\SILK-GUI\5.ico')

root.mainloop()
python tkinter python-idle
1个回答
0
投票

否。 IDLE是使用tkinter用Python编写的应用程序。有一些组件可能会用在其他应用程序中,并且将来可能会使用更多,但是这些组件可能会发生变化,并且不正式支持外部使用。

© www.soinside.com 2019 - 2024. All rights reserved.