Re: [Tutor] Graphical/web program
On 13/01/18 05:15, Pat Martin wrote: > I was thinking of turning this into a web app (one that is just run on my > local machine) something like have a form with text box, checkbox and > radio buttons for the options/flags. > > My question is, is something like that practical? Will I be able to write > to a local file (home/user/.ssh/config) with say a flask app? I don't know > flask but am willing to learn it and thought this might be a good program > for it. It is definitely doable and as a learning experience on web apps its a good starter project. You will need to run a web server on your machine, but Flask provides a basic server that will suffice. It can write to a file or a database. Looking beyond the web aspect, if its just for your local machine use then a desktop GUI might be a more suitable mechanism than a web page, it would be lighter weight and offer more design features. But if you want to learn Flask then this is a good starting point. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] python gui Tkinter
please any one give me the code for username (entryfld)- pwrd (entryfld) login(button),changepwrd(button) virtualkeyboard-user has to be use dis keyboard once click on login button regester page open register page content 1.emply name(entryfld) 2.emply id(entryfld), 3.mbil no(entryfld), 4. RFID(entryfld) , 5.back (button), 6.clearbtn(button), 7. ok(button) next user want to clear employee details click on clear button1. employee id text feild shd open click on ok employee id should be removed please i need this code immediatly any one tell me please. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python gui Tkinter
On 13/01/18 12:05, mamatha n wrote: please any one give me the code for username (entryfld)- pwrd (entryfld) login(button),changepwrd(button) virtualkeyboard-user has to be use dis keyboard once click on login button regester page open register page content 1.emply name(entryfld) 2.emply id(entryfld), 3.mbil no(entryfld), 4. RFID(entryfld) , 5.back (button), 6.clearbtn(button), 7. ok(button) next user want to clear employee details click on clear button1. employee id text feild shd open click on ok employee id should be removed please i need this code immediatly any one tell me please. Terribly sorry but that's not how this list works. You provide the code and we help you fix any problems. Anybody giving you the code is doing you a grave disservice in the long term as you will not learn. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python gui Tkinter
On 13/01/18 12:05, mamatha n wrote: > please any one give me the code for We don't write code for you (unless you want to pay one of us as a contractor) But we can point you at some examples: > username (entryfld)- > pwrd (entryfld) > login(button),changepwrd(button) So far very basic Tkinter, any tutorial would cover it. You could try mine at: http://www.alan-g.me.uk/tutgui.htm > virtualkeyboard-user has to be use dis keyboard Thisis not a TKinter function its an OS feature. Tkinter will work with whichever keyboard is present. If you want to create your own vuirtual keyboard using Tkinter then thats possible but quite a lot of work. (More tedious than technically difficult though) > once click on login button regester page open GUIs don't usually have the content of pages - unless you want a tabbed notebook metaphor. If so look at the ttk module But usually I'd expect a pop up dialog box to appear, or for the login window to disappear ad a new main window to appear. You need to clarify how it works. > register page content 1.emply name(entryfld) > 2.emply id(entryfld), > 3.mbil no(entryfld), 4. RFID(entryfld) , 5.back (button), > 6.clearbtn(button), 7. ok(button) Since all you need are entry fields and buttons you should have no problem putting it together with the help of any Tkinter tutorial. You probably want to use the grid layout manager for this. > please i need this code immediatly any one tell me please. You will need to write it, if you get stuck feel free to ask, but its all very basic and covered in any tutorial. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installing python and numpy on the Mac (OSX)
Peter Hodges writes: > Hi. I downloaded Python 3.6 from the python site, then followed online > directions for pip to install numpy (in users? —user was in the > example). > When I start IDLE in the Python 3.6 in Applications and then type > import numpy as np I get the following: > import numpy as np > Traceback (most recent call last): > File "", line 1, in > import numpy as np > ModuleNotFoundError: No module named ‘numpy' > > Does this mean I need to set the $PATH with some new pathname? no > Or move the numpy directory into the python 3.6 directory? no > Or? first, (optional but I'd reccommend to) disinstall numpy using the same pip script that you used to install it, something like $ pip uninstall numpy # possibly using sudo next, you must be sure that Python 3.6 has pip, either $ /path/to/python3.6 -m ensurepip --user or (if you are installing in a virtual environment) $ /path/to/python3.6 -m ensurepip the above is going to install pip if it is not already present in the environment of Python 3.6 --- please see https://docs.python.org/3/library/ensurepip.html for the gory details finally, install numpy for 3.6 $ /path/to/python3.6 -m pip install --user numpy The command "/path/to/python3.6 -m modulename ..." ensures that the module and the Python version are matching one with the other. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] question about metaclasses
On Wed, Jan 10, 2018 at 07:29:58PM +0100, Peter Otten wrote: [...] > elif not isinstance(obj, property): > attrs[attr] = property(lambda self, obj=obj: obj) > PS: If you don't remember why the obj=obj is necessary: > Python uses late binding; without that trick all lambda functions would > return the value bound to the obj name when the for loop has completed. This is true, but I think your terminology is misleading. For default values to function parameters, Python uses *early* binding, not late binding: the default value is computed once at the time the function is created, not each time it is needed. So in this case, each of those property objects use a function that sets the default value of obj to the current value of obj at the time that the property is created. Without the obj=obj parameter, Python creates a *closure*. A closure is a computer-science term for something like a snap shot of the environment where the function was created. If we had written this instead: attrs[attr] = property(lambda self: obj) the name "obj" doesn't refer to a local variable of the lambda function. Nor does it refer to a global variable, or a builtin function. It refers to a "non-local variable": it belongs to the function that surrounds the lambda function, not the lambda itself. And so Python would create a *closure* for the lambda function so that when it eventually gets called, it knows where to find the value of obj. And *that* process, of looking up the value of obj from a closure, uses late binding: all the lambda functions will refer to the same environment, which means they will also see the same value for obj. Namely the last value obj received when the outer function (the one that the closure refers back to) completed. Here's another example to show the difference. Rather than use lambda, I'm going to use regular "def" to prove that this has nothing to do with lambda itself, the rules apply every time you create a function. Start with the closure version: # --- cut here %< --- def factory_closure(): # Create many new functions, each of which refer to i in its # enclosing scope. functions = [] for i in range(5): def f(): return i # << this i is a NONLOCAL variable functions.append(f) return functions functions = factory_closure() # All the closures refer to the same thing. for f in functions: print(f.__closure__) # And the functions all see the same value for i print([f() for f in functions]) # --- cut here %< --- And here is a version which avoids the closure issue by using the function parameter default value trick: # --- cut here %< --- def factory_no_closure(): # Create many new functions, each of which refer to i using # a parameter default value. functions = [] for i in range(5): def f(i=i): return i # << this i is a LOCAL variable functions.append(f) return functions functions = factory_no_closure() # None of the functions need a closure. for g in functions: print(g.__closure__) # And the functions all see different values for i print([g() for g in functions]) # --- cut here %< --- In practice, this is generally only an issue when single invocation of a factory function creates two or more functions at once, and that generally means inside a loop: def factory(): for i in something: create function referring to i If your factory only returns one function at a time, like this: def factory(i): create function referring to i for n in something: factory(n) then each function still uses a closure, but they are *different* closures because each one is created on a different invocation of the factory. That's another way to avoid this "early/late binding" problem. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor