Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

align two buttons same column?

I recently got back into Python, decided to give GUI a try. Yes, i know, there is better language to make GUI. However, I am familiar with Python I've used it, just never tried GUI.

I want to put two buttons next to each other using .grid() I know in .pack() can be done but I have programs organizing it so I used grid instead.
I'm using Tkinter and I have this:

[Image: Z81Tinx.png]mg]

the code:
PHP Code

<?php 
import Tkinter 
as tk
import tkFont
import ttk

def cbc
(id, tex):
    return 
lambda : callback(id, tex)

def callback(id, tex):
    
s = "wut \n"
    
tex.insert(tk.END, s)
    
tex.see(tk.END)

root = tk.Tk()
root.resizable(0,0)
dFont=tkFont.Font(family="Arial", size=10)

l1 = tk.Label(root, text="RTMPin:")
e1 = tk.Entry(root,width=50)

l1.grid(row=0, column=0, sticky="e")
e1.grid(row=0, column=1, sticky="news")

l2 = tk.Label(root, text="RTMPout:")
e2 = tk.Entry(root)

l2.grid(row=1, column=0, sticky="e")
e2.grid(row=1, column=1, sticky="news")

l3 = tk.Label(root, text="Log:")
e3 = tk.Text(master=root, width=50, height=5, font=dFont)

l3.grid(row=3, column=0, sticky="e")
e3.grid(row=3, column=1, sticky="news")

l4 = tk.Label(root)
e4 = tk.Button(root, text="start", command=cbc("1", e3))
e4b = tk.Button(root, text="stop")

l4.grid(row=2, column=0, sticky="e")
e4.grid(row=2, column=1, sticky="e")
e4b.grid(row=2, column=2, sticky="w")

l5 = tk.Label(root)
e5 = tk.Button(root, text='Exit', command=root.destroy)

l5.grid(row=4, column=0, sticky="e")
e5.grid(row=4, column=1, sticky="news")

root.columnconfigure(0, weight=0)
root.columnconfigure(1, weight=1)

root.mainloop() 
Off topic, but you should try integrating your python code into VB or something, it will make things so, so much easier once you get a hang of it! Python wasn't made to ever create GUIs.
[Image: c5bcca49a3c4d3c6c7a27493507eba95.png]
(Nov 21, 2016 01:20 PM)Bossk Wrote:  Off topic, but you should try integrating your python code into VB or something, it will make things so, so much easier once you get a hang of it! Python wasn't made to ever create GUIs.

yeah, i know, I just wanted to try.

any tuts on how to integrate Python with vb?
(Nov 21, 2016 02:55 PM)-Matatan- Wrote:  yeah, i know, I just wanted to try.

any tuts on how to integrate Python with vb?

You really need the IronPython interpreter. It's based on the CLR VM.
http://blogs.msmvps.com/theproblemsolver...-from-net/
SRPP Discord Server

I am a professional network/cloud security architect.
My Old Tutorials
You should try Qt, everyone should !
(Nov 21, 2016 05:18 PM)SIM-1866423 Wrote:  You should try Qt, everyone should !

I've heard good things, never tried it myself though, but people who's ability I trust have spent a bit of time with it.

Of what I've used personally, I quite like glade and it's been very helpful. If you take a look at it I could dig up some old scripts from a synthesiser, but may not have the .glade files onhand.
(Nov 21, 2016 05:18 PM)SIM-1866423 Wrote:  You should try Qt, everyone should !

thanks ill give it a try.
So I took your advice, I installed pyqt, and it is so much better! Thanks!

[Image: 62Pi2jW.png]
(Nov 25, 2016 12:06 PM)-Matatan- Wrote:  So I took your advice, I installed pyqt, and it is so much better! Thanks!

[Image: 62Pi2jW.png]

Glad to hear that, the only problem about qt and biggest one(for my opinion) freezing problem while using "while" loop.You cant use directly but with multiprocessing is just fine, good luck :)
(Nov 25, 2016 02:27 PM)SIM-1866423 Wrote:  Glad to hear that, the only problem about qt and biggest one(for my opinion) freezing problem while using "while" loop.You cant use directly but with multiprocessing is just fine, good luck :)


thanks for the tip. I'll keep that in mind.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by QU35TFeb 10, 2022 10:19 AM 2 128 Feb 10, 2022 10:19 AM
Last Post: QU35T
[.NET] by Haxor1974Oct 31, 2017 08:44 PM 2 159 Oct 31, 2017 08:44 PM
Last Post: ppaida
[Python] by thePoltergeistMar 7, 2017 12:24 PM 6 190 Mar 7, 2017 12:24 PM
Last Post: thePoltergeist