Heisenberg1927 Posted February 14, 2019 Share Posted February 14, 2019 I have created a complex program(i can share if anyone wants for reference), which simply takes input and gives output in the console.The start of the program is:- a = int(input("Range - ")) .......(The whole program is long..so not putting it here for now)..... And i want to create an application using 'tkinter'..with an entry widget as the input (which is stored in variable 'a', after clicking a button). My program doesn't have any functions and I would like to just use that value of a which I get as input to be used as it is used in my actual program. . In short after i get input, my program should carry out the operations and then output the answer to the user in the app. Please help for getting input and showing output.. Link to comment Share on other sites More sharing options...
Sensei Posted February 14, 2019 Share Posted February 14, 2019 Search net for "tkinter example", "tkinter tutorial" or similar keywords. For instance https://likegeeks.com/python-gui-examples-tkinter-tutorial/ What you need is Entry widget https://likegeeks.com/python-gui-examples-tkinter-tutorial/#Get-input-using-Entry-class-Tkinter-textbox After clicking button, there is called procedure: https://likegeeks.com/python-gui-examples-tkinter-tutorial/#Handle-button-click-event Inside of it, you need to read Entry widget user data, parse it the way you want (like in command-line script), and show output. How to show output? Try Label widget or yet another Entry widget (it could be with disabled editing of content). Link to comment Share on other sites More sharing options...
Heisenberg1927 Posted February 15, 2019 Author Share Posted February 15, 2019 Well i looked into it ...(thanks)...my program actually takes a range from user and then takes a number of data that is given by user in the form of range earlier. For this I have created a for loop which takes data as per range. My program then makes a list of that data ....so I created a loop of entry widgets as per range...so now how do I compile that data in a list so that my program can run further?..or is there any other way in which I can take data from the user and compile it into a list. I have attached the whole programs for ref 1) main (graphic)- is the GUI I was trying to work out. 2)main-is the actual working program It's fot custom use so u might not get point of it ....Cheers main(graphic).py main.py Link to comment Share on other sites More sharing options...
Sensei Posted February 15, 2019 Share Posted February 15, 2019 You have two options: - forget about main.py... just copy its functionality to main(graphics).py.. and instead of taking arguments from shell replace it by GUI equivalent code. - call main.py from main(graphics).py. To learn how to do it search net for "call python script with arguments from python" e.g. https://stackoverflow.com/questions/3781851/run-a-python-script-from-another-python-script-passing-in-args Then you will have to analyze output. Link to comment Share on other sites More sharing options...
wtf Posted February 17, 2019 Share Posted February 17, 2019 As an alternative, may I suggest running a webserver, running your Python program as a CGI script, and using simple HTML forms for data input. Different approach to give a Python program a GUI. Link to comment Share on other sites More sharing options...
Heisenberg1927 Posted February 18, 2019 Author Share Posted February 18, 2019 I am sorry but i already made changes in the script so that I can use it in tkinter.. On 2/17/2019 at 2:37 PM, wtf said: As an alternative, may I suggest running a webserver, running your Python program as a CGI script, and using simple HTML forms for data input. Different approach to give a Python program a GUI. However I am caught up in another problem :- a=[12, 13, 14] b=[(12, 13), (13, 14)] I want to say remove the values stored in b[0] to be removed from 'a'. With this I am gonna complete my program so...this is the final step.. cheers how can I do it? (I tried directly removing by a.remove(), but it didn't ..probably because it identifies (12, 13) as 1 element, but still ...help me out) Link to comment Share on other sites More sharing options...
wtf Posted February 18, 2019 Share Posted February 18, 2019 1 hour ago, Heisenberg1927 said: I am sorry but i already made changes in the script so that I can use it in tkinter.. However I am caught up in another problem :- a=[12, 13, 14] b=[(12, 13), (13, 14)] I want to say remove the values stored in b[0] to be removed from 'a'. With this I am gonna complete my program so...this is the final step.. cheers how can I do it? (I tried directly removing by a.remove(), but it didn't ..probably because it identifies (12, 13) as 1 element, but still ...help me out) So how would you extract 12 and 13 from (12,13)? You can work this out by experimenting with the syntax. Link to comment Share on other sites More sharing options...
Sensei Posted February 18, 2019 Share Posted February 18, 2019 1 hour ago, Heisenberg1927 said: how can I do it? Brute-force method would be manual go through the all elements in array, compare, and if criterion is met, remove element at specified index.. Link to comment Share on other sites More sharing options...
Heisenberg1927 Posted February 19, 2019 Author Share Posted February 19, 2019 13 hours ago, Sensei said: Brute-force method would be manual go through the all elements in array, compare, and if criterion is met, remove element at specified index.. Thanks that worked And my program is now complete. Thanks guys/girls !! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now