Re: Feasibility of console based (non-Gui) Tkinter app which can accept keypresses?
You may want to check Urwid instead. 2018-07-11 16:22 GMT-03:00 Jim Lee : > On 07/11/18 07:09, jkn wrote: > >> Hi All >> This is more of a Tkinter question rather than a python one, I >> think, but >> anyway... >> >> I have a Python simulator program with a Model-View_Controller >> architecture. I >> have written the View part using Tkinter in the first instance; later I >> plan >> to use Qt. >> >> However I also want to be able to offer an alternative of a console-only >> operation. So I have a variant View with the beginnings of this. >> >> Naturally I want to keep this as similar as possible to my Tkinter-based >> view. I >> had thought that I had seen a guide somewhere to using Tk/Tkinter in a >> non-GUI >> form. I don't seem to be able to track this down now, but I have at least >> been >> successful in hiding ('withdrawing') the main Frame, and running a main >> loop. >> >> The bit which I am now stumbling on is trying to bind key events to my >> view, >> and I am wondering if this actually makes any sense. In the absence of a >> GUI I >> want to accept keypresses to control the simulation. But in a console app >> I will >> have no visible or in focus window, and therefore at what level would any >> keys be bound? Not at the widget level, nor the frame, and I am not sure >> if the >> the root makes sense either. >> >> So I am looking for confirmation of this, and/or whether there is any way >> of >> running a Tkinter application in 'console' mode, running a main loop and >> both outputting data and accepting, and acting on, key presses. >> >> Thanks >> J^n >> >> > I think the general answer is no, but beyond that, it may be worth > considering switching from an MVC architecture to a simpler > frontend-backend, especially if you intend to add a third interface (Qt): > > MVC w/Tk, console, Qt: > > Seven conceptual modules (three controllers, three views, one model) > Two abstraction layers (controller<->model, model<->view) > > Frontend-backend w/Tk, console, Qt: > > Four conceptual modules (three frontends, one backend) > One abstraction layer (frontend<->backend) > > -Jim > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: best way to remove leading zeros from a tuple like string
>>> repr(tuple(int(i) for i in s[1:-1].split(','))) '(128, 20, 8, 255, -1203, 1, 0, -123)' 2018-05-21 4:26 GMT-03:00 Peter Otten <__pete...@web.de>: > bruceg113...@gmail.com wrote: > > > Looking over the responses, I modified my original code as follows: > > > s = "(128, 020, 008, 255, -1203,01,-000, -0123)" > ",".join([str(int(i)) for i in s[1:-1].split(",")]) > > '128,20,8,255,-1203,1,0,-123' > > I think this looks better with a generator instead of the listcomp: > > >>> ",".join(str(int(i)) for i in s[1:-1].split(",")) > '128,20,8,255,-1203,1,0,-123' > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
2017-01-04 7:39 GMT-03:00 Steve D'Aprano : > On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote: > > Aside: you've actually raised a fascinating question. I wonder whether > there > are any programming languages that understand URLs as native data types, so > that *source code* starting with http:// etc is understood in the same way > that source code starting with [ is seen as a list or { as a dict? > ... > Some Smalltalk implementations have something that comes close: st> 'https://python.org' asUrl retrieveContents `asUrl` would be a string method returning a URL instance, which also has a convenient method `retrieveContents` wrapping an http client. Not hard to do with Python, I think this could be an interesting exercise for a learner. -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
2017-01-04 7:39 GMT-03:00 Steve D'Aprano : > On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote: > > Aside: you've actually raised a fascinating question. I wonder whether > there > are any programming languages that understand URLs as native data types, so > that *source code* starting with http:// etc is understood in the same way > that source code starting with [ is seen as a list or { as a dict? > ... > Some Smalltalk implementations have something that comes close: st> 'https://python.org' asUrl retrieveContents `asUrl` would be a string method returning a URL instance, which also has a convenient method `retrieveContents` wrapping an http client. Not hard to do with Python, I think this could be an interesting exercise for a learner. -- https://mail.python.org/mailman/listinfo/python-list
Re: OT: limit number of connections from browser to my server?
Long shot here: Create a JS framework for loading resources in a better way: 1. Load HTTP and your JS core. 2. Load the rest of the resources via JS (maybe using promises for chaining the requests one after the other) -- https://mail.python.org/mailman/listinfo/python-list