Python内部终端缩小

Python内部终端缩小

我的问题出在我的代码的某个地方,但我找不到在哪里,问题是当我按下其中一个按钮时,程序中集成的 xterm 窗口会在两个按钮之间调整大小(空间很小)

import Tkinter
from Tkinter import *
import subprocess
import os
from os import system as cmd



def test():
    os.system('sudo xterm -into %d -geometry 200x40 -sb -e overscan &' % wid)

def sysinfo():
    os.system('xterm -into %d  -sb -e systeminfo &' % wid)

def ipconf():
    os.system('xterm -into %d -sb -e ipconfig &' % wid)

def grpmw():
    os.system('xterm -into %d -geometry 0x0 -sb -e firefox -height 900 -width 1440 *snip*' % wid)

def lout():
    os.system('xterm -into %d -sb -e pkill python' % wid)

def rboot():
    os.system('xterm -into %d -sb -e sudo reboot' % wid)

def pwoff():
    os.system('xterm -into %d -sb -e sudo poweroff' % wid)


WINDOW_SIZE = "1440x900"
top = Tkinter.Tk()
top.geometry(WINDOW_SIZE)

Button1  = Tkinter.Button(top, text ="Systeem informatie opvragen", command=sysinfo)
Button1.pack(side=LEFT,  anchor=NW)

Button2  = Tkinter.Button(top, text ="IP adres achterhalen",        command=ipconf)
Button2.pack(side=LEFT,  anchor=NW)

Button3  = Tkinter.Button(top, text ="Zwarte balken weghalen",      command=test)
Button3.pack(side=RIGHT, anchor=N )

Button4  = Tkinter.Button(top, text = "21 Groep Myworkplace",       command = grpmw)
Button4.pack(side=RIGHT, anchor=N )

Button6  = Tkinter.Label(top, text = "                                                    ")
Button6.pack(side=RIGHT, anchor=N )

Button5  = Tkinter.Button(top, text = "Uitloggen", command = lout)
Button5.pack(side=RIGHT, anchor=N )

Button7  = Tkinter.Label(top, text = "                                      ")
Button7.pack(side=LEFT,  anchor=N )

Button8  = Tkinter.Button(top, text = "Herstarten", command = rboot)
Button8.pack(side=LEFT,  anchor=N )

Button9  = Tkinter.Button(top, text = "Afsluiten", command = pwoff)
Button9.pack(                     )

termf = Frame(top, height=1000, width=1000)

termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()

def send_entry_to_terminal(*args):
    """*args needed since callback may be called from no arg (button)
   or one arg (entry)
   """
    cmd("%s" % (BasicCovTests))


if __name__ == "__main__":
     top.title('KEUZE MENU')
     top.mainloop()

------------------编辑 1------------------

我注意到我的帖子表达不清楚,抱歉,就是我的意思。不知怎的,当我按下其中一个按钮时,它会卡在“afsluiten”按钮的边缘之间。

但当我删除标签时,框架会调整为更适合的尺寸,就像截屏

------------------编辑 2------------------

所以...我想我已经让它工作了,但我不确定,因为我的屏幕是黑的,我发现当你使用比如说 side=LEFT 两次时,它会阻挡屏幕左侧从第一个按钮的开始到第二个按钮的结束,使得整个区域无法使用,所以我使用了 grid,问题是终端超出了屏幕范围,所以我用 pack 做了一个子项,现在我的屏幕是黑的,哈哈哈,我会随时向你们更新最新情况

相关内容