Python Forum
[Tkinter] Entry widget to variable
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()
Reply
#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)
Reply
#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
Reply
#4
IPRangeEntry.place(x=115, y=44)
should be on the next separate line

IPRangeEntry = Entry(main)
IPRangeEntry.place(x=115, y=44)
Reply
#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 :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: could not convert string to float: '' fron Entry Widget russellm44 5 491 Mar-06-2024, 08:42 PM
Last Post: russellm44
  [Tkinter] entry widget DPaul 5 1,433 Jul-28-2023, 02:31 PM
Last Post: deanhystad
  Tkinter Exit Code based on Entry Widget Nu2Python 6 2,874 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  [Tkinter] Update variable using tkinter entry methon drSlump 6 5,093 Oct-15-2021, 08:01 AM
Last Post: drSlump
  method to add entries in multi columns entry frames in self widget sudeshna24 2 2,214 Feb-19-2021, 05:24 PM
Last Post: BashBedlam
  Entry Widget issue PA3040 16 6,655 Jan-20-2021, 02:21 PM
Last Post: pitterbrayn
  [Tkinter] password with Entry widget TAREKYANGUI 9 5,775 Sep-24-2020, 05:27 PM
Last Post: TAREKYANGUI
  [Tkinter] Get the last entry in my text widget Pedroski55 3 6,295 Jul-13-2020, 10:34 PM
Last Post: Pedroski55
  How to retreive the grid location of an Entry widget kenwatts275 7 4,475 Apr-24-2020, 11:39 PM
Last Post: Larz60+
  Problem with setting variable within a Entry validatecommand kenwatts275 1 1,853 Mar-31-2020, 01:53 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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