Python Forum
thinker button gui place next to each other
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
thinker button gui place next to each other
#6
HI again,
i modify something, do anyone knows how to let the button to place next to each other.
right now the there's label in top and bottom. The button is replace middle of label.
is there any possible to replace "ping test", and "clear' button next to each other.

i try with side=left, but it's not what i wants.
any other advice.



import tkinter as tk
import subprocess
def clear_text():
    result.destroy()
 
def ping():
    cmd = ["ping", entry.get(), "-n", "2"]
    output = subprocess.check_output(cmd)
    #print (output)
    #output = subprocess.check_output("ping {} -c 2".format(entry.get()), shell=True)
    #print under console
    #print('>', output)
    #with open('test.txt', 'w') as f:
    #cls    print(output, file=f)
     
 
    # put result in label
    #result['text'] = output.decode('utf-8')
    result['text'] = output.decode('big5')
 
my_gui = tk.Tk()
entry = tk.StringVar()
 
my_gui.geometry('300x300')
my_gui.title("Get output inside GUI") 
 
tk.Label(my_gui, text="Enter target IP or host as required.",bg = 'red').pack(side='top') 
tk.Entry(my_gui, textvariable=entry, bg = 'yellow').pack()
#tk.Button(my_gui,text="Ping Test", command=ping).pack() 
#tk.Button(my_gui,text="Clear", command=clear_text).pack(ipadx=10) 
tk.Button(my_gui,text="Ping Test", bd=2, command=ping).pack(side='top') 
tk.Button(my_gui,text="Clear", bd=2, command=clear_text).pack(side='top') 


# label for ping result
result = tk.Label(my_gui,bg='blue', height="20", width="50")
result.pack()
 
 
 
my_gui.mainloop()
thanks
Reply


Messages In This Thread
RE: thinker button gui place next to each other - by jacklee26 - Jul-03-2019, 05:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Place QT Window in the middle AlphaInc 10 2,255 Aug-03-2023, 05:40 PM
Last Post: Axel_Erfurt
  [Tkinter] how to make label or button not visible with the place method? nowayj63 2 2,852 Jan-03-2023, 06:29 PM
Last Post: Yoriz
  Label.Place did not work? ATARI_LIVE 15 5,338 Sep-18-2020, 04:22 PM
Last Post: ATARI_LIVE
  [Tkinter] How to place scroll bar correctly scratchmyhead 1 3,968 May-18-2020, 04:17 PM
Last Post: scratchmyhead
  How to use place holders in tkinter sqlite scratchmyhead 1 1,838 May-12-2020, 06:13 PM
Last Post: Larz60+
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,042 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020