Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Entry widget to variable
#1
Hey guys. Im a bit of a scrub when it comes to coding, specially with python. Just need some help with getting the ip/port range from the entry widgets up to their corresponding variables. this is what i have so far. And no i'm not trying to be some 1337 hakzorz i run servers at home and i like poking at my network to make sure i havnt opened something i shouldnt have or to see whats happening on my network. I havent really had much luck finding anything when googling This is what i have so far.


from tkinter import *




main = Tk()
main.title('Blackmap')
main.geometry("700x700")
main.resizable(0, 0)

# Variables
IPRange = '0.0.0.0'
PortRange = '0'

# Functions
def setiprange():
    IPRange = IPRangeEntry.get()
    print("The IP range set is:", IPRange)


def setportrange():

    print("The Port range set is:", PortRange)


# Labels
Label(main, text="Options").place(x=500, y=15)
Label(main, text="Scan Type").place(x=350, y=15)
Label(main, text="Enable").place(x=579, y=15)
Label(main, text="Disable").place(x=634, y=15)

# Buttons
SetIPbttn = Button(text="Set IP Range", fg="green", command=setiprange,  height=1, width=11).place(x=5, y=40)
SetPortRangebttn = Button(text="Set Port Range", fg="green", command=setportrange, height=1, width=11).place(x=5, y=80)

# Radio Buttons
Drb1 = Radiobutton(main).place(x=645, y=30)
Drb2 = Radiobutton(main).place(x=645, y=52)
Drb3 = Radiobutton(main).place(x=645, y=74)
Drb4 = Radiobutton(main).place(x=645, y=96)
Drb5 = Radiobutton(main).place(x=645, y=118)
Drb6 = Radiobutton(main).place(x=645, y=140)
Drb7 = Radiobutton(main).place(x=645, y=162)
Drb8 = Radiobutton(main).place(x=645, y=184)
Drb9 = Radiobutton(main).place(x=645, y=206)
Drb10 = Radiobutton(main).place(x=645, y=228)
Erb1 = Radiobutton(main).place(x=590, y=30)
Erb2 = Radiobutton(main).place(x=590, y=52)
Erb3 = Radiobutton(main).place(x=590, y=74)
Erb4 = Radiobutton(main).place(x=590, y=96)
Erb5 = Radiobutton(main).place(x=590, y=118)
Erb6 = Radiobutton(main).place(x=590, y=140)
Erb7 = Radiobutton(main).place(x=590, y=162)
Erb8 = Radiobutton(main).place(x=590, y=184)
Erb9 = Radiobutton(main).place(x=590, y=206)
Erb10 = Radiobutton(main).place(x=590, y=228)


# Entry Boxes
IPRangeEntry = Entry(main).place(x=115, y=44)
PortRangeEntry = Entry(main).place(x=115, y=84)


main.mainloop()

Quote
#2
IPRangeEntry = Entry(main).place(x=115, y=44)
PortRangeEntry = Entry(main).place(x=115, y=84)
place() returns None. You have to first store the Entry instance so you can access in the function.

PRangeEntry = Entry(main)
PRangeEntry.place(x=115, y=44)
Quote
#3
(Sep-20-2019, 02:28 PM)woooee Wrote:
IPRangeEntry = Entry(main).place(x=115, y=44)
PortRangeEntry = Entry(main).place(x=115, y=84)
place() returns None. You have to first store the Entry instance so you can access in the function.

PRangeEntry = Entry(main)
PRangeEntry.place(x=115, y=44)


when changing
IPRangeEntry = Entry(main).place(x=115, y=44)
to
IPRangeEntry = Entry(main)IPRangeEntry.place(x=115, y=44)

i just get a syntax error
Quote
#4
IPRangeEntry.place(x=115, y=44)
should be on the next separate line

IPRangeEntry = Entry(main)
IPRangeEntry.place(x=115, y=44)
Quote
#5
(Sep-20-2019, 03:20 PM)Yoriz Wrote:
IPRangeEntry.place(x=115, y=44)
should be on the next separate line

IPRangeEntry = Entry(main)
IPRangeEntry.place(x=115, y=44)

Ahh thank you. That fixed it :)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Inserting numbers into entry box in a widget richard13 1 241 Aug-11-2019, 11:37 AM
Last Post: Yoriz
  [PyQt] Collect entry from textline Widget via UI file mart79 3 226 Aug-05-2019, 01:40 PM
Last Post: Denni
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 508 Mar-18-2019, 05:36 PM
Last Post: woooee
  Update plot by <Return> bind with entry widget Zorro 1 483 Mar-09-2019, 12:27 PM
Last Post: Zorro
  [Tkinter] Tkinter Entry widget and KeyPad intrgration chiragarya1992 0 998 Aug-11-2018, 01:09 AM
Last Post: chiragarya1992
  [Tkinter] How to restrict characters used in an Entry widget? Nwb 2 3,010 Jun-20-2018, 12:55 PM
Last Post: Nwb
  [Tkinter] Thousand Separator Entry Widget Cursor Pos Trouble papatubies 4 1,599 Jul-24-2017, 02:51 PM
Last Post: DeaD_EyE
  [Tkinter] Update value in Entry widget dannyH 7 13,872 Apr-02-2017, 10:12 AM
Last Post: dannyH
  [Tkinter] Entry widget : unable to get the text entered dlemper 2 8,153 Oct-11-2016, 12:32 AM
Last Post: dlemper

Forum Jump:


Users browsing this thread: 1 Guest(s)