Comments (7)
Hmm..
I ran a couple of quick tests and it looks like the variables are stored in an id
field on the ast
objects. So, to solve this, I think it'll just be a matter of finding all the nodes in the tree that have matching id
s.
I'll have to play around with it a bit.
Thanks for the bug!
from gooey.
Probably a bit of a naive question as I don't quite understand how the whole thing works internally but wouldn't there a way to plug the Gooey logic (get the different options and their types, display a beautiful GUI out of it) only in the parse_args
method so that everything that would have been evaluated normally without Gooey is evaluated the same way with Gooey.
from gooey.
The tricky part is getting all of the info before the client program actually runs. It's not as simple -- at least how I'm reasoning about it (which could be wrong) -- as getting reference to and reading what's in the ArgumentParser
at run time. Once their main
function kicks off, Gooey is out of the loop, and so has no way of getting the values stored within.
I've been playing around with a few ways of getting around this limitation -- Specifically, ones that don't involve parsing the AST a million times looking for id
s :) The front runner is currently using compile
to control the execution of the client code. It still involved parsing the ast to find the initial ArgumentParser
assignment. However, once I have that, I can inject my own variable into a modified version of their code, and use compile
and exec
to partially run their main
function thus populating the parser for me (complete with any variables like bar
in your above example).
In my small scale testing, it's been pretty successful. But I'm not sure how robust a strategy it is to partially run a source file in this manner. I suspect it would be brittle with other people's code. Or it could work way better than what's there now. Who knows!
At any rate, a fix to your issue (using one of the above strategies) will be pushed soon.
from gooey.
I guess I have missed something but a simple solution seems to be to launch the GUI as part of the parse_args
method.
I wrote a very simple way to do so if you are interested : https://gist.github.com/SylvainDe/9fc6502b778267e86c64 . The point is that the decorator would change the behavior of the parse_args
method to call graphical_parse_args
instead. That method would launch a GUI and get the values out of it (when "start" is clicked for instance) and then the values are fed to the original parse_args method.
from gooey.
Man, do I feel like a dope! Yeah, that makes way more sense than what I was doing.
I think I got wrapped up in my ways a bit, there. Gooey came about from something I was working on called ArgDoc
, which in turn came about from playing around with parsing the ast
. Each project built on the previous project's parsing bits until, well, I guess I thought ripping values out of the ast was the only way to do things.
Your suggestion is definitely the correct route to take.
docopt
support is planned. So, maybe I can redeem my parsing obsession there...
from gooey.
I'm glad you like the suggestion. However, I'm not quite sure you will
manage to re implement all existing features with this solution though.
Indeed, I cannot really see how you'd manage to perform the restart from
there but I'll let you think about it :-p
On 5 Sep 2014 00:48, "Chris" [email protected] wrote:
Man, do I feel like a dope! Yeah, that makes way more sense than what I
was doing.I think I got wrapped up in my ways a bit, there. Gooey came about from
something I was working on called ArgDoc, which in turn came about from
playing around with parsing the ast. Each project built on the previous
project's parsing bits until, well, I guess I thought ripping values out of
the ast was the only way to do things.Your suggestion is definitely the correct route to take.
docopt support is planned. So, maybe I can redeem my parsing obsession
there...—
Reply to this email directly or view it on GitHub
#37 (comment).
from gooey.
Alright, this should be fixed now.
I got hung up where you expected: figuring out how to restart.
I ended up modifying things so that rather than doing all of the ast
parsing funniness, Gooey simply creates a copy of the client's source and sticks a return parser
statement on the line just before the call to parser.parse_args()
. Once that's done, I can import the modified version of the code, run its main
method, and bam, a fully populated version of the ArgumentParser
is returned to me. Easy Peasy.
Not the most elegant of solutions, but it seems to work.
from gooey.
Related Issues (20)
- Gooey application hangs up during task execution because of an UnicodeDecodeError HOT 1
- option for a 'next step' button? HOT 1
- MultiDirChooser does not show paths in textbox after selecting folders HOT 1
- customize format of MultiFileChooser as list
- When I add a log-in page,it will appear during codes running
- Screen issues
- Master branch Gooey freezes when clicking Start
- Can I use a loop to execute some commands? HOT 1
- Progress bar time remaining goes missing when progress_regex not a match
- installing version 1.2.0 on m1 chip
- update release requirements for Python 3.11 on conda-forge HOT 2
- Current package via pip & system install throws RuntimeError HOT 1
- Do you have a download button component HOT 1
- Subparser sections not switching due to a wxPython problem?
- Is there a TUI equivalent of this? HOT 1
- "ArguementParser" Undefined HOT 1
- No status info is showed anymore after pyinstaller pkg to one exe file... What should I do next? HOT 5
- problem with pyinstaller. 'NoneType' object has no attribute 'isatty' HOT 1
- program_name missed while launching gooeyparser
- Gooey 1.0.8.1 Validation Not Working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gooey.