Web Development
int64 0
1
| Data Science and Machine Learning
int64 0
1
| Question
stringlengths 35
6.31k
| is_accepted
bool 2
classes | Q_Id
int64 5.14k
40.5M
| Score
float64 -1
1.2
| Other
int64 0
1
| Database and SQL
int64 0
1
| Users Score
int64 -6
163
| Answer
stringlengths 19
4.91k
| Python Basics and Environment
int64 0
1
| ViewCount
int64 12
475k
| System Administration and DevOps
int64 0
1
| Q_Score
int64 0
346
| CreationDate
stringlengths 23
23
| Tags
stringlengths 6
68
| Title
stringlengths 12
138
| Networking and APIs
int64 0
1
| Available Count
int64 1
31
| AnswerCount
int64 1
35
| A_Id
int64 5.3k
72.3M
| GUI and Desktop Applications
int64 1
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | Background
I am working on a program that needs to find a list of open Metro apps. I originally tried using pure python with ctypes and using win32 api. Unfortunately, I couldn't get the names of Metro apps. So I moved on to IronPython thinking I could leverage a .net function or two to get what I want. No luck.
Where I am at
I can easily get a list of running processes and their PID, but filtering the Metro apps from the non-metro apps is proving near impossible. Also, I need to get the HWND of that window so I can interact with it.
What Won't Work
EnumWindows doesn't seem to work. FindWindowEx seems promising, but I am not sure how to do this.
Thanks in advance.
EDIT: I am now able to get what I want using IsImmersiveProcess, but the process list is doesn't include the Windows Apps. | true | 29,197,996 | 1.2 | 0 | 0 | 0 | I don't think MS allows this functionality. As an alternative, you can have the user put their mouse over the window and press a keyboard shortcut (What I am doing).
That is the best one can do. | 1 | 121 | 0 | 0 | 2015-03-22T18:11:00.000 | c#,python,windows-8,windows-store-apps,ironpython | IronPython-List Open Metro Apps only | 0 | 1 | 1 | 29,978,493 | 1 |
0 | 0 | Up until now to move widgets I have been issuing another .place on it. I wonder if that is creating another instance of the widget in memory or not?
If it is creating another copy in memory, what is the correct way to move a widget when using place? Do I need to keep destroying the widget and placing it perhaps over and over? | false | 29,200,214 | 0 | 0 | 0 | 0 | Now that I think about it, as long as I do a .place_forget() prior to any .place that should take care of any extra instances in memory. Can anyone confirm? | 1 | 13 | 0 | 0 | 2015-03-22T21:43:00.000 | python,widget | Python: When using place what is the correct way to move widgets? | 0 | 1 | 1 | 29,200,555 | 1 |
0 | 0 | I want to make a heads-up display that pops up it's frame, taking focus from the previous application and then gives focus back to that application when it's done.
wxPython frames have Hide and Show methods that work but don't focus the application. Also, there's SetFocus which you'd think would do it but doesn't.
Update
I found a nasty hack that works. Rather than hide and show the frame, you save the app state and close the app instead of hiding. Then when you want to show again you spark a new one in a new multiprocessing.Process. Hardly ideal though. I hope someone has something better.
Clarification
To clarify, I'm trying to get the keyboard focus, not just to get the frame on top of the stack.
This issue might be specific to OS X. | true | 29,222,699 | 1.2 | 0 | 0 | 2 | You might be able to steal focus by calling Raise on the frame. There is the wx.STAY_ON_TOP style flag that could also be applied. Then you might be able to just use the frame's Show and Hide methods to make it work.
Depending on what exactly you want to do, you might take a look at the ToasterBox widget. I can't recall if it actually steals focus, but it just pop up and go away on its own, which is handy in some cases. | 0 | 542 | 0 | 1 | 2015-03-24T00:03:00.000 | python,wxpython,wxwidgets | How can a wxpython frame "steal" and "return" focus similar to the Dash app? | 0 | 1 | 1 | 29,233,860 | 1 |
0 | 0 | I've recently begun programming with QPython3 on my android phone, and I've found it slightly annoying that the console pops up whenever I run a script. I often have it sending the output through a Toast since I usually only need the information for a second.
Is there a way I can make it, either within my script or in the settings of QPython3, that the console is default to the background while running a script?
Thank you | false | 29,247,204 | 0 | 0 | 0 | 0 | Try to insert the "#qpy:console" into your script, does it work for you ? | 0 | 733 | 0 | 0 | 2015-03-25T04:00:00.000 | qpython,qpython3 | QPython 3 console | 0 | 1 | 1 | 29,415,173 | 1 |
0 | 0 | Can I control the "Wrap Text" property of a cell using Python+xlwings? | false | 29,258,237 | 0.099668 | 0 | 0 | 2 | For anybody like me who comes to this now and doesn't find these solutions are working, I found accessing the pywin32 API directly with work_sheet.range('A:A').api.WrapText = True worked in Python 3.7 and xlwings 0.15.8 in Windows 7 and Excel 2010. | 1 | 2,055 | 0 | 2 | 2015-03-25T14:17:00.000 | python,excel,python-2.7,xlwings | Does xlwings support "Wrap Text" property? | 0 | 1 | 4 | 57,833,558 | 1 |
0 | 0 | I have a working C program and now I'm embedding a python script implementing a specific function.
The question is, the arguments passed into Python is a complicated(I mean nested) C structure defined in C. And I hope the solution would be able to do the two ways communication easily:
1.Create structure in C, and pass it into Python. Let the Python do some modification.
2.Create the structure in Python. And pass it back to C.
I was trying "SWIG" to generate some wrappers for the structure, as well as some helper functions using SWIG for Python so that it could return me some nested part of the structure so that I could visit the structure through Python easily.
Will this be a good solution or I may miss some very simple way of solving it? | false | 29,269,401 | 0 | 1 | 0 | 0 | In my experience, SWIG should be able to handle arbitrarily nested structs the way you'd "expect". – brunobeltran0 | 0 | 134 | 0 | 0 | 2015-03-26T01:12:00.000 | python,c,structure,swig,mixed-programming | How do I pass C structure into Python when embedding a Python module in a C program | 0 | 1 | 1 | 32,625,890 | 1 |
0 | 0 | I have written a program which use thread in Tkinter. It works fine when I run this program on linux, but when the same program run on Windows it doesn't work.
Problem exist when loop (which is run under thread) is ended and call function which cause to appear Toplevel window
Any suggestions?? | false | 29,295,830 | 0.664037 | 0 | 0 | 4 | Generally speaking, you can't use threading with Tkinter. Or more accurately, you can only access tkinter widgets and functions from the thread that created them. If your thread is creating a window, that simply will not work on windows, and may work non-deterministically on other platforms. | 1 | 391 | 0 | 0 | 2015-03-27T08:00:00.000 | python,multithreading,tkinter | Is there any difference in threading between Linux and Windows on python? | 0 | 1 | 1 | 29,298,504 | 1 |
0 | 0 | Just like the title implies, is there any difference? I was using pygame.display.flip and I saw on the Internet that instead of using flip they used pygame.display.update. Which one is faster? | false | 29,314,987 | 0.049958 | 0 | 0 | 1 | pygame.display.flip() updates the whole screen.
pygame.display.update() updates only specific section but with no arguments works similar to the pygame.display.flip(). | 0 | 55,985 | 0 | 42 | 2015-03-28T08:03:00.000 | python,pygame,python-2.x | Difference between pygame.display.update and pygame.display.flip | 0 | 2 | 4 | 67,557,797 | 1 |
0 | 0 | Just like the title implies, is there any difference? I was using pygame.display.flip and I saw on the Internet that instead of using flip they used pygame.display.update. Which one is faster? | false | 29,314,987 | 1 | 0 | 0 | 9 | Flip will always update the entire screen. Update also update the entire screen, if you don't give argument. But if you give surface(s) as arguments, it will update only these surfaces. So it can be faster, depending on how many surfaces you give it and their width and height. | 0 | 55,985 | 0 | 42 | 2015-03-28T08:03:00.000 | python,pygame,python-2.x | Difference between pygame.display.update and pygame.display.flip | 0 | 2 | 4 | 29,316,190 | 1 |
0 | 0 | I realize the short answer may be 'no,' but perhaps this is worth asking again.
If I am witting a Kivy app with a couple thousand of lines - then would it be possible to write some classes in another kv file?
This would make it so much easier to edit, correct errors, make changes... etc.
Just to clarify - the .KV files would be a continuation of each other - not pointing to a parallel app.
Some expert insight would be greatly appreciated - Thank you. | false | 29,332,868 | 0.132549 | 0 | 0 | 2 | I believe you can create muliple .kv files and can include at one place (root file) by this way only you can distribute/branch your code
Kivy documentation clearly says "A kv file must contain only one root widget at most"
means only one kv main file. even if you run multiple instances of Mainapp class
I'm newer to the Kivy, so please correct me if I'm wrong.
Thank you ! | 0 | 11,529 | 0 | 21 | 2015-03-29T18:10:00.000 | python,kivy | Is it possible to read from more than one .kv file in Kivy app? | 0 | 1 | 3 | 61,815,101 | 1 |
0 | 0 | I saw that there are 2 ways for use the ui file with pyside. It's possible to convert or to load file. What is the best performance between this 2 solutions ?
Thanks in advance | false | 29,345,617 | 0 | 0 | 0 | 0 | Conversion processes the ui file once and creates a static module. Loading the ui file at runtime processes it every time the application is run. So obviously any difference in performance is going to be roughly equal to the overhead of processing the ui file.
Having said that, runtime performance is probably not a good reason for choosing between them. Most people prefer one over the other simply because it provides a better fit for their development process. | 0 | 38 | 0 | 0 | 2015-03-30T11:56:00.000 | python,pyside,benchmarking | performance between converted and loaded file with pyside | 0 | 1 | 1 | 29,354,758 | 1 |
0 | 0 | As I am more familiar with tkinter than Qt, is it possible to have a tkinter frame populate with a C++ application to enable the manipulation of visio files. The end result would hopefully be to have a portable .exe that would connect to an access database for line item tracking, and the Visio "canvas" to manipulate visual layouts of work spaces.
I am very new to programming, and learning as I go... | true | 29,351,650 | 1.2 | 0 | 0 | 2 | I don't think you can embed ActiveX controls like the one provided by Visio (it's probably what you refer to as "visio canvas") in tkinter. Even with Qt, this may be not that straightforward.
The second thing is, "visio canvas" won't work without Visio installed - not sure if that's okay with you. Means, your users first would have to install Visio (and provide a license) and then your .exe which uses Visio as "canvas".
If you want a sand-alone exe, I would recommend you to use whatever is available in your framework instead of Visio. | 0 | 96 | 0 | 0 | 2015-03-30T16:40:00.000 | python,ms-access,visual-c++,tkinter,visio | C++ "canvas" inside of tkinter frame to manipulate MS visio files | 0 | 1 | 1 | 29,352,732 | 1 |
0 | 0 | resized_image = Image.resize((100,200));
Image is Python-Pillow Image class, and i've used the resize function to resize the original image,
How do i find the new file-size (in bytes) of the resized_image without having to save to disk and then reading it again | false | 29,368,155 | 0 | 0 | 0 | 0 | You can't. PIL deals with image manipulations in memory. There's no way of knowing the size it will have on disk in a specific format.
You can save it to a temp file and read the size using os.stat('/tmp/tempfile.jpg').st_size | 1 | 1,687 | 0 | 2 | 2015-03-31T12:00:00.000 | python,python-imaging-library,pillow | How to get image size in python-pillow after resize? | 0 | 1 | 2 | 29,368,336 | 1 |
0 | 0 | My application have a window which handle key press events. When user press a key I run some long tasks and during a task I update a label on the window. To update the label while task is still running I call the following code.
while gtk.events_pending():
gtk.main_iteration(False)
This update the label but problem is that it process all the events including key presses. if user press a key while a tasks is running calling main_iteration start processing that task. I want that it should only update the label but any other events should not be processed . Those events should be processed when task is completed.
One way to do this is to remove the key press handler or with in that keypress handler check if task is running then ignore the key presses but in this way keypresses will be lost. I want that somehow it should only update the label but leave other events and those events should be handled after task is completed and application become idle. Is there a way to do this?
Thanks | false | 29,395,356 | 0.197375 | 0 | 0 | 1 | You want the .queue_draw() and related GtkWidget methods. Note that these will mark your widget as needing redraw when you get back to the main loop; I don't think GTK+ has a method for drawing right now (but marking as dirty and letting the system redraw when it's ready is usually better for optimization reasons). | 0 | 280 | 0 | 0 | 2015-04-01T15:52:00.000 | python,events,widget,gtk,redraw | How to redraw gtk widget in python without calling gtk.main_iteration? | 0 | 1 | 1 | 29,396,431 | 1 |
0 | 0 | My question is : is it possible to put ads on a tkinter program , something like google ads or something , because I made a program which a lot of people started using and I am not getting any benefits from it , is there a way ? | true | 29,446,102 | 1.2 | 0 | 0 | 3 | There is nothing built-in to tkinter, nor available as a third party library, that makes it possible to display an ad and receive revenue from it. | 0 | 1,029 | 0 | 3 | 2015-04-04T11:55:00.000 | python,python-2.7,tkinter | Advertising on a tkinter program | 0 | 1 | 2 | 29,446,371 | 1 |
0 | 0 | I am running a simple client-server program written in python, on my android phone using QPython and QPython3. I need to pass some commandline parameters. How do I do that? | false | 29,456,031 | 0 | 0 | 0 | 0 | Just write a wrapper script which get the parameters and pass to the real script using some function like execfile, and put the script into /sdcard/com.hipipal.qpyplus/scripts or /sdcard/com.hipipal.qpyplus/scripts3 (for qpython3).
Then you can see the script in scripts when clicking the start button. | 0 | 2,584 | 0 | 2 | 2015-04-05T09:44:00.000 | qpython,qpython3 | Passing commandline arguments to QPython | 0 | 1 | 2 | 29,654,733 | 1 |
0 | 0 | How do I setup Spyder to highlight and auto-complete kivy files (.kv)? | true | 29,467,603 | 1.2 | 0 | 0 | 1 | (Spdyer dev here) There is no way at the moment for Spyder to highlight kivy files, sorry :-( | 1 | 707 | 0 | 0 | 2015-04-06T08:09:00.000 | python,kivy,spyder | How do I setup Spyder to highlight and auto-complete kivy files (.kv)? | 0 | 1 | 1 | 29,635,815 | 1 |
0 | 0 | The question I have as the title says is on the idea of setting up a graph in pygame that graphs sub-pixel coordinates.
Something a friend and I spoke of was how I could try to make a function graphing program for fun in python, and I thought about how I could use it, but I found a few issues.
The first one was the use of range, due to it using integers and not floats, but arange from numpy fixed that problem, but that brings me to the second issue.
The idea for the graph I thought about so that it would be simple, not making massive thick lines or odd shaped one, is that it uses display.set_at to make a single pixel a color. And for simple graphs, this works perfectly. But when I went into more complicated graphs, I ran into two main errors:
The first error is that the graph shows pixels without any line between them, the idea of the line was the illusion of having all of the pixels near each other. But I found that with a range step of one in range, it leaves this gap. In theory, using arange with a step of .01, the gaps would vanish all together, but this brings to the second problem.
The display.set_at does not work with sub-pixel coordinates. Would anyone be able to suggest a way to make this work? It would be most appreciated. | false | 29,484,408 | 0 | 0 | 0 | 0 | Instead of setting each individual pixel, use pygame's line drawing function to draw a line from the current coordinate to the next instead of using sub-pixel coordinates (pygame.draw.line or even pygame.draw.lines).
This way, the "gaps" between two points are filled; no need for sub-pixel coordinates.
You just have to draw the lines in the right order; just ensure the coordinates are sorted.
Other than that, you could also simple convert your sub-pixel coordinates by casting the x/y values to integers. | 0 | 312 | 0 | 0 | 2015-04-07T05:29:00.000 | python,numpy,pygame | Pygame, sub-pixel coordinates. | 0 | 1 | 1 | 29,488,142 | 1 |
0 | 0 | I run python using Winpython. I would like to use the GUI libraries from wxpython in my Spyder IDE. I tried the wxpython installer but for some reason the packages are not copied to the WinPython\python\Lib\site-packages folder. I also tried the build it "Winpython Control Panel" which is supposed to add new packages but dragging and dropping the installer file didn't really work.
How can I install wxpython so that I can use it from Winpython Spyder? | false | 29,509,526 | 0.197375 | 0 | 0 | 1 | So I managed to find a solution to my problem.
Winpython has the option to "register" the distribution, this will add associate file extensions, add icons, and importantly for my case, register WinPython as a standard Python distribution. When I registered my copy of Winpython, in the Advanced tab of the Winpython control panel , the wxPython installer was able to see Winpython in the Windows registry and copy all the files to the corresponding folders.
Now if I run: import wx, it works | 1 | 1,863 | 0 | 1 | 2015-04-08T08:25:00.000 | python,wxpython,spyder | Installing/running wxpython on Winpython Spyder | 0 | 1 | 1 | 29,619,247 | 1 |
0 | 0 | How can I choose photo in Kivy ?
I couldn't see a module to see and select a photo.
from kivy.uix.filechooser import FileChooserListView
shows files by names
Thank you | false | 29,513,493 | 0 | 0 | 0 | 0 | There is no built in widget for displaying photos, the Kivy philosophy is instead to make it easy to build such a thing from component widgets, e.g. in this case layouts and Image widgets probably.
That said, we would be happy to include image browser implementations in the Kivy garden user repository. | 0 | 259 | 0 | 0 | 2015-04-08T11:36:00.000 | python,kivy | Kivy Photo Chooser | 0 | 1 | 1 | 29,522,735 | 1 |
0 | 0 | I'm making a program that streams my screen to another computer(like TeamViewer), I'm using sockets, PIL ImageGrab, Tkinter.
Everything is fine but the screenshot I get from ImageGrab.grab() is without the mouse cursor, which is very important for my program purpose.
Do you know how can I take screenshot with the mouse cursor? | false | 29,524,885 | 0.53705 | 0 | 0 | 3 | The cursor isn't on the same layer as the desktop or game your playing, so a screenshot won't capture it (try printscreen and paste into mspaint). A workaround is to get the position of the cursor and draw it on the image. you could use win32gui.GetCursorPos(point) for windows. | 0 | 2,661 | 0 | 6 | 2015-04-08T20:37:00.000 | python,screenshot,python-imaging-library | Include mouse cursor in screenshot | 0 | 1 | 1 | 29,624,597 | 1 |
0 | 0 | I am making a game for a presentation and I cannot seem to understand how to make a delay in Python.
For example, whenever I press the D key, my character not only moves but also changes pictures so it looks like it's running.
I have the movement part down, I just need to slow down the changing of the sprite so that it doesn't look like he's running a million miles per hour. I have set the FPS. | false | 29,526,895 | 0 | 0 | 0 | 0 | The command turtle.down() will work, I guess | 1 | 165 | 0 | 1 | 2015-04-08T23:09:00.000 | python,pygame | How Do you make a delay in python without stoping the whole program | 0 | 1 | 2 | 29,527,035 | 1 |
0 | 0 | I am trying to program an application that runs a HTTP server as well as a GUI using Tornado and PyQt4 respectively. I am confused about how to use these two event loops in parallel. Can this be done with the multiprocessing module? Should the HTTP server be run in a QtThread? Or is a bash script the best way to go to run both of these processes at the same time? | false | 29,551,003 | 0 | 0 | 0 | 0 | You won't need a bash script. Probably simplest to write a PyQt application and have the application launch the web server. The server may be in a separate thread or process depending on your requirements, but I'd start by having a single thread as a first draft and splitting it out later.
Having the PyQt app as your main thread makes sense as your GUI is going to be responsible for user inputs (start/stop server, etc) and program outputs (server status, etc) and therefore it makes sense to make this the controlling thread with references to other objects or threads. | 1 | 757 | 0 | 0 | 2015-04-09T23:49:00.000 | python,bash,qt,pyqt,tornado | How can I combine PyQt4 and Tornado's event loops into one application? | 0 | 1 | 2 | 29,551,539 | 1 |
0 | 0 | I am trying to build a GUI which will:
Load a file with parameters which describe certain type of problem.
Based on the parameters of the file, show only certain tab in QTabwidget (of many predefined in Qt Designer .ui)
I plan to make a QTabwidget with, say 10 tabs, but only one should be visible based on the parameters loaded. Enabling certain tab is not an option since it takes to many space and the disabled tabs are grey. I do not want to see disabled tabs.
Removing tab could be an option but the index is not related to a specific tab so I have to take care of the shift in the indices. And furthermore if user loads another file with different parameters, a good tab should be added and the current one removed.
My questions are:
How to do this effectively?
Is it better to use any other type of widget?
In Qt designer, is it possible to define many widgets one over another and then just push the good one in front. If yes, how? And how to edit and change any of them?
If using RemoveTab, how to use pointers on tabs, rather than indices?
I use PyQt4 | false | 29,560,307 | 0 | 0 | 0 | 0 | I see that this thread is kinda old. But I hope this will still help.
You can use the remove() method to "hide" the tab. There's no way to really hide them in pyqt4. when you remove it, it's gone from the ui. But in the back end, the tab object with all your settings still exist. I'm sure you can find a way to improvise it back. Give it a try! | 0 | 7,611 | 0 | 1 | 2015-04-10T11:28:00.000 | python,pyqt,qt-designer,qtabwidget | PyQT Qtabwidget add, remove, hide, show certain tab | 0 | 1 | 2 | 44,781,276 | 1 |
0 | 0 | I installed (extracted) Kivy (Kivy-1.9.0-py3.4-win32-x86.exe) on my PC (Win7 32bit). Now whenever trying to run a file using kivy-3.4.bat getting an error message within a window...
python.exe- Entry point not found
The procedure entry point inflateReset2 could not be located in the dynamic link library zlib1.dll.
Once click on the "Ok" button I see
[Critical ] [app] unable to get a window, abort
on CMD.
I think this is a problem related to my system and Python more than Kivy. Can anyone tell me what is the problem and how to solve it?
This is amazing!! Even in StackOverFlow no one could give me any solution!! | false | 29,566,947 | 0.049958 | 0 | 0 | 1 | This happened to me because an old zlib1.dll was being loaded from somewhere in my PATH. I copied a new version to system32 and it solved the problem. | 0 | 12,725 | 1 | 5 | 2015-04-10T17:03:00.000 | python-3.x,system,kivy | Python | Python.exe- Entry point not found | 0 | 2 | 4 | 35,697,811 | 1 |
0 | 0 | I installed (extracted) Kivy (Kivy-1.9.0-py3.4-win32-x86.exe) on my PC (Win7 32bit). Now whenever trying to run a file using kivy-3.4.bat getting an error message within a window...
python.exe- Entry point not found
The procedure entry point inflateReset2 could not be located in the dynamic link library zlib1.dll.
Once click on the "Ok" button I see
[Critical ] [app] unable to get a window, abort
on CMD.
I think this is a problem related to my system and Python more than Kivy. Can anyone tell me what is the problem and how to solve it?
This is amazing!! Even in StackOverFlow no one could give me any solution!! | false | 29,566,947 | 0.197375 | 0 | 0 | 4 | Yes, I know this post is a bit old, but maybe someone else searches this.
I got the same error. And really, I just tried to start the python script via MS Powershell instead of CMD. I just wanted to use the PS one time.
And it worked, at least for me.
So, if you encounter this error, try to use the Powershell :) | 0 | 12,725 | 1 | 5 | 2015-04-10T17:03:00.000 | python-3.x,system,kivy | Python | Python.exe- Entry point not found | 0 | 2 | 4 | 34,912,630 | 1 |
0 | 0 | I want to install pygame library on Ubunbu 14.10. I am using Python 2.7.x. At this time I found dependences problems with python-numpy dependence., because it uses a previous version of gcc that 14.10 uses that's why I am stuck with this, my question is: is there any way to install pygame on 14.10?
best | false | 29,593,223 | 0.197375 | 0 | 0 | 1 | If you open up the terminal
type in
sudo apt-get install python-pygame
It should download and install the dependencies required for pygame. | 1 | 386 | 1 | 0 | 2015-04-12T18:46:00.000 | python-2.7,pygame,ubuntu-14.10 | install python pygame on ubuntu 14.10 | 0 | 1 | 1 | 30,444,254 | 1 |
0 | 0 | Is there any way to detect the color that the turtle is standing on in python?
For example if the the turtle is on a black colored space, he moves forward. | true | 29,649,743 | 1.2 | 0 | 0 | 1 | Quickly glancing over the turtle documentation, nope, there's no way to detect colors.
You should probably keep a record of which spaces you have drawn so far, adding to the collection whenever you draw a new space. Then, when you want to know the color of an old space, you only need to search through the collection.
What collection you ought to use depends on what kind of spaces we're talking about here. If the spaces are nice tessellated squares, like a chessboard, you could probably get away with a dictionary whose keys are (row,col) coordinate tuples. | 0 | 1,770 | 0 | 0 | 2015-04-15T12:04:00.000 | python,turtle-graphics | Turtle graphics color detection | 0 | 1 | 1 | 29,649,944 | 1 |
0 | 0 | i'm trying to create chatbox on kivy python. one of the most difficult is to create class with super class Label, which can support select its text like a TextInput class. Can somebody help me? | false | 29,679,264 | 0.53705 | 0 | 0 | 3 | Why not just use a TextInput field? change the appearance parameters so it looks like a label and disable input to the field. | 1 | 891 | 0 | 4 | 2015-04-16T15:24:00.000 | python,kivy | Label with selectable text | 0 | 1 | 1 | 29,679,556 | 1 |
0 | 0 | I would like to copy the console output to ask a question about a program that's not working. but it seems the normal way of holding down text doesn't highlight the text for selection like in the editor.
Is there a way to copy the text from qpython console? | false | 29,706,559 | 0 | 0 | 0 | 0 | You can only press-and-hold the console and then select the "Copy All" option.
At least I am doing so.
I think there is no way to copy specific text. | 1 | 471 | 0 | 0 | 2015-04-17T18:11:00.000 | qpython | How do you copy text from qpython console? | 0 | 1 | 1 | 30,407,110 | 1 |
0 | 0 | I have a Python\Tkinter Label formatting question.
I have a simple main window with a Label that has its textvariable bound to a DoubleVar()
I want to display the value in the DoubleVar() as a US dollar amount,
as in "$ 123.45"
How can I have the Label display the value the way I want?
I know I could change the textvariable to a StringVar() but then I have lost the precision of the DoubleVar(). I need it for other calculations in the app.
I have also tried sub-classing the Label class but couldn't figure out what method to override when the textvariable value is accessed.
How do I tell a Label how I want a number formatted? | false | 29,759,754 | 0.066568 | 0 | 0 | 1 | You can't. At least, not automatically. You can use a separate label just for the "$", or manually format the string for the label. | 0 | 3,745 | 0 | 0 | 2015-04-20T22:44:00.000 | python,tkinter,label | Python tkinker label formatting | 0 | 1 | 3 | 29,759,880 | 1 |
0 | 0 | I m working on a python project currently, It is a application which don not interact with internet.GUI is being dine with wxpython. Is there code available in python which can simulate button click. | false | 29,764,235 | 0.761594 | 0 | 0 | 5 | I depends on what you really need it to do. Do you just want cause the same code to be executed as would be done when the user clicks the button? Or do you need to have a real system level mouse event occur on the native UI button as if there was a real user doing it?
For the former you just need to cause the event handler function to be called from wherever you need it to be done. You can create a matching event object and use wx.PostEvent as suggested, or simply call the event handler method directly. Or for a little bit better programming style, refactor and move the guts of the event handler to a separate function and call it from the event handler and also wherever else you need to simulate the effects of clicking the button.
For having real system level events being sent to the native widget there is the wx.UIActionSimulator class, which can be used to simulate the mouse or keyboard at a lower level than posting wx events, so the UI behaves exactly the same as if there was a real user doing it. I would guess that 95% of the time that this is overkill for cases like what you describe, and also more complex than the above, but it's there if you really need it. | 0 | 1,909 | 0 | 2 | 2015-04-21T06:11:00.000 | python-2.7,wxpython,buttonclick,simulate | simulating button click in python | 0 | 1 | 1 | 29,778,393 | 1 |
0 | 0 | In pygame I can use pygame.mixer.music to load and play long audio files (by streaming), or pygame.mixer.Sound & pygame.mixer.Channel for shorter ones (that are loaded entirely into memory) - as I understand correctly.
I'd like to use both of these methods. However I'd also like to know, when playback of given Channel or Music has just finished. There are methods for that: set_endevent() - on both music and channel. When I use pygame.locals.USEREVENT as a type of event, when channel's playback is finished i receive event with code == <channel_id>. When music's playback is finished, code is always 0. Thus I cannot tell the difference, whether it is music that stopped, or channel with id 0.
Is there any way to tell them apart? | false | 29,805,701 | 0 | 0 | 0 | 0 | -.- I misunderstood the documentation. There is said:
The type argument will be the event id sent to the queue. This can be any valid event type, but a good choice would be a value between pygame.locals.USEREVENT and pygame.locals.NUMEVENTS. If no type argument is given then the Channel will stop sending endevents.
And I understood I should choose either USEREVENT or NUMEVENTS. I was constantly looking for a way to use some new event types but I thought it is impossible. So I chose USEREVENT, hoping that no other pygame module uses it, and thinking it's better than NUMEVENTS.
But then I came up with idea, that maybe these types are just numbers and "between" means literally between. So after I checked it appeared that USEREVENT == 24 and NUMEVENTS == 32. So I can basically use any number from 25 to 32...
Silly me. :)
Only one thing remain: let's take that I used 25 as type for Channel.set_endevent(). How to get my channel id now?
Edit:
Ok, now I have a full image. It's even better - I think. If I understand correctly: pygame.USEREVENT (equal 24) is the first of many events up to pygame.NUMEVENT (equal 32). Any of them have an attribute code that can be used for whatever I want (and Channel uses it to put its id). So basically I can use pygame.USEREVENT + 0 for channels and pygame.USEREVENT + 1 for music.
Correct me please if I'm wrong. | 0 | 196 | 0 | 0 | 2015-04-22T18:11:00.000 | python,events,audio,pygame | How to differentiate endevent of music and channel? | 0 | 1 | 1 | 29,806,090 | 1 |
0 | 0 | In PyQt4, I want to present a QPushButton that looks like the down-arrow button in QComboBox. Feasible, and if so, how?
I don't need help getting my new widget-combination acting like a QComboBox (see below). I only want the QPushButton display/graphic to look like the down-arrow button in a QComboBox - and tips/code on how to overlay that graphic (especially if said graphic comes via a file) onto my own QPushButton.
More details, context:
I'm seeking to replace a QComboBox widget with a QLineEdit + QCalendarWidget, because QDateEdit isn't as customizable as I need (I think...). The thought is to place a QPushButton immediately adjacent (on the right-side) of the QLineEdit to make it things look like regular QComboBox as much as possible. Then said button will .exec_() the QCalendarWidget (which is technically wrapped by a QDialog).
Let me know if this doesn't make sense, and I can provide further or clarified context. | true | 29,806,160 | 1.2 | 0 | 0 | 2 | You can try a QToolButton with no text and the arrowType property set to Qt.DownArrow. eg: myqtoolbutton.setArrowType(Qt.DownArrow). | 0 | 2,863 | 0 | 0 | 2015-04-22T18:36:00.000 | python,pyqt,qcombobox,qpushbutton,qdate | PyQt: display QPushButton that looks like the down-arrow button in QComboBox | 0 | 1 | 1 | 29,907,644 | 1 |
0 | 0 | When PyScripter opens another window (eg. a pygame window or matplotlib graphs), I can't edit code until I close the other window. I can move around the code and delete bits, but can't type.
The problem didn't use to occur because the pygame window opened with another program (I think it was python.exe). I don't recall changing anything that would have made this happen; I have always just run a sctipt called Game.py from inside pyscripter which opens the pygame window using pygame.init().
I have python 2.7.9 32bit, pyscripter 2.6.0 32bit (the problem also occured for pyscripter 2.5.3), windows 7 64bit.
How can I either get pygame to open in the python.exe, or change pyscripter so that I can edit scripts ? | false | 29,848,354 | 0 | 0 | 0 | 0 | Woops I just needed to change run->python engine from internal to remote. | 0 | 233 | 0 | 0 | 2015-04-24T13:07:00.000 | python,pygame,pyscripter | Pyscripter not editable when a sub window is open | 0 | 1 | 1 | 29,859,267 | 1 |
0 | 0 | I've been programming some Kivy/Python apps on my Motorola Moto G mobile phone.
I've got a few handy little apps, that have been working OK for a few months.
Today, I launched one of the apps - through the QPython interface, and it didn't work.
So, I tried another of my apps and that failed to launch for the same reason. In fact, all of them fail to launch for the same reason.
The error shown on screen ends with:
File "/QPython/core/build/python-install/lib/python2.7/UserDict.py", line 23, in getitem
KeyError: 'ANDROID_APP_PATH'
I presume that something on the phone has taken an upgrade - and broken something.
I assume that is the case because this problem affects all of the Kivy apps I was using.
Anyone else encountered this? | true | 29,851,825 | 1.2 | 0 | 0 | 2 | You need to have
#qpy:kivy
part in the first line.
At least that was what happened to me.
I suppose that is because QPython is finding what type of app is it. | 0 | 543 | 0 | 1 | 2015-04-24T15:41:00.000 | android,python,kivy,qpython | KeyError: 'ANDROID_APP_PATH' | 0 | 1 | 1 | 30,407,066 | 1 |
0 | 0 | I am fairly new to Python and to GUI programming, and have been learning the Tkinter package to further my development.
I have written a simple data logger that sends a command to a device via a serial or TCP connection, and then reads the response back, displaying it in a ScrolledText widget. In addition, I have a button that allows me to save the contents of the ScrolledText widget into a text file.
I was testing my software by sending a looped command, with a 0.5 second delay between commands. The aim was to test the durability of the logger so it may later be deployed to automatically monitor and log the output of the devices it is connected to.
After 30-40 minutes, I find that the program crashes on my Windows 7 system, and I suspect that it may be caused by a memory issue. The crash is a rather nondescript, "pythonw.exe has stopped working" message. When I monitor the process using Windows Task Manager, the memory used by pythonw.exe increases each time a response is read, and will eventually reach nearly 2Gb.
It may be that I need to rethink my logic and have the software log to the disk in 'real time', while the ScrolledText box overwrites the oldest data after x-number of lines... However, for my own education, I was wondering if there was a better way to manage the memory used by ScrolledText?
Thanks in advance! | true | 29,896,688 | 1.2 | 0 | 0 | 0 | In general, no, there are no memory limitations with writing to a scrolled text widget. Internally, the text is stored in an efficient b-tree (efficient, unless all the data is a single line, since the b-tree leaves are lines). There might be a limit of some sort, but it would likely be in the millions of lines or so. | 0 | 72 | 0 | 0 | 2015-04-27T13:05:00.000 | memory,logging,textbox,tkinter,python-3.4 | Are there memory limitations when outputting to a ScrolledText widget? | 0 | 1 | 1 | 29,900,168 | 1 |
0 | 1 | I have a pyQT4 application where the user is asked for a savefile (QFileDialog and all that...)
One annoyance is it does not remember the last directory so multiple call always defaults to the working directory of the application (or whatever I set the 3rd argument to)
If I set the option to not use the native file browser it remembers but "it is not native to windows" (note this doesn't bug me as I am a linux user, but others are not...)
One option I was considering was saving the last working directory and populating the 3rd argument with that for every call but this seems quite brutal, especially as it seems matplotlib appears to be remembering the last directory (so it is possible)
Any ideas?
filename = QtGui.QFileDialog.getSaveFileName(self, "Save Plot to CSV", '', "CSV Data (*.csv)") | false | 29,914,909 | 0 | 0 | 0 | 0 | The QFileDialog.saveState() and QFileDialog.restoreState() methods can save and restore the current directory of the dialog box. | 0 | 305 | 0 | 1 | 2015-04-28T09:02:00.000 | windows,python-3.x,pyqt4 | pyQT4 native file dialog remembering last directory | 0 | 1 | 1 | 29,999,330 | 1 |
1 | 0 | Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.
Any hints links examples welcome. | true | 29,928,485 | 1.2 | 0 | 0 | 0 | Here is what I have sort of put together by pulling several threads online:
Ruby On Rails seems to be more popular than python at this moment.
If you go python, Flask and Django are good templates.
bokeh seems to be a good way of plotting to a browser.
AFAIK, there is no way to take an existing PyQt or pyqtgraph application and have it run on the web.
I am not sure how Twisted (Tornado, Node.js and Friends) fits in to the web SaaS, but I see it referred to occasionally since it is asynchronous event-driven.
People often suggest using Rest, but that seems slow to me. Not sure why... | 0 | 1,640 | 0 | 4 | 2015-04-28T19:43:00.000 | python,django,pyqt,saas,pyqtgraph | Displaying pyqtgraph and pyqt widgets on web | 0 | 2 | 2 | 29,947,088 | 1 |
1 | 0 | Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.
Any hints links examples welcome. | false | 29,928,485 | 0 | 0 | 0 | 0 | If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the tool for this job. VisPy does have some early browser support but this has only been demonstrated with ipython notebook. | 0 | 1,640 | 0 | 4 | 2015-04-28T19:43:00.000 | python,django,pyqt,saas,pyqtgraph | Displaying pyqtgraph and pyqt widgets on web | 0 | 2 | 2 | 29,987,875 | 1 |
0 | 0 | Is it possible to mount more than one image AND text on a Tkinter button?
Or, is it possible to put a FRAME containing images + text on a button?
I want a big button containing multiple widgets that, when taken together, fully describe the option the user will be able to choose.
I appreciate any suggestions!! | true | 29,933,581 | 1.2 | 0 | 0 | 2 | Is it possible to mount more than one image AND text on a Tkinter button?
Strictly speaking, no, it is not possible.
Or, is it possible to put a FRAME containing images + text on a button?
Yes, though it probably won't work on OSX. It would probably take you less time to actually try it than to type in the question on stackoverflow. A little research goes a long way.
You can also simply not use a button. Just use a frame or canvas, and set up bindings on the container and/or it's contents to react to a button click. | 0 | 917 | 0 | 2 | 2015-04-29T03:02:00.000 | python,python-2.7,user-interface,button,tkinter | Python Tkinter: multiple images and text on a BIG button? | 0 | 1 | 1 | 29,941,782 | 1 |
0 | 0 | I want the user to be able to select the items on a PyGTK ComboBox, while not being able to write in the combo. He/She should be allowed just to select one of the items.
So I can't use set_active(False), for it will disable the combo.
How can I do this ? | true | 29,969,746 | 1.2 | 0 | 0 | 2 | GTK+ 2 has a type GtkComboBoxEntry that always has the entry box you don't want (and handles some model-related things). Your Glade file uses a GtkComboBoxEntry. Change it to GtkComboBox and, assuming everything else is set up properly (your model is correct and you have a GtkCellRendererText), you should be good to go.
(Thanks to gregier in irc.gimp.net/#gtk+ for some information.) | 0 | 667 | 0 | 0 | 2015-04-30T13:57:00.000 | python,gtk,pygtk | How do I disable edition of a PyGtk Combobox? | 0 | 1 | 1 | 29,976,673 | 1 |
0 | 0 | I am using wxPython ObjectListView and it is very easy to use. Now I need to render a wx.Color as a column but I haven't found a way in the documentation. Basically I have list of items each of them have the following attributes: name, surname and hair color. Hair color is a RGB color and I would like to show it as a column in my ObjectListView.
Is there a way to do it ?
Many thanks | false | 29,990,202 | 0 | 0 | 0 | 0 | For the future: what I did was to show the color as a background of the row of the list. | 0 | 360 | 0 | 0 | 2015-05-01T15:46:00.000 | python,wxpython,objectlistview-python | ObjectListView wxPython: how to show a wx.Color | 0 | 1 | 2 | 30,030,742 | 1 |
0 | 0 | So, I'm working with pygame in python 2.7.9 and I'm trying to make some kind of zoom, to view details of a fractal.
I can easily draw a Sierpinski triangle using polygons, my idea is to zoom a area of the triangle and see details of the depth without pixelation.
So far, I can zoom in but the surface gets pixelated
Is there anyway to do this?
Thanks. | false | 29,994,341 | 0 | 0 | 0 | 0 | First make a canvas and triangle with a big size and Zoom out. So when you zoom in, it won't get pixelated. | 1 | 1,289 | 0 | 0 | 2015-05-01T20:09:00.000 | python,pygame,zooming,pixel | Zoom in and Zoom Out Pygame | 0 | 1 | 1 | 29,994,418 | 1 |
0 | 0 | I have a tuple of constants:
WIN = 640, 360, "Example", False, 'tool' # x, y, title, resizable, style
And now to use it I have to type in this:
app = pyglet.window.Window(WIN[0], WIN[1], WIN[2], WIN[3], WIN[4])
Is there a method to split tuple into separate elements like this:
app = pyglet.window.Window(WIN.extract()) ? | true | 30,000,275 | 1.2 | 0 | 0 | 0 | app = pyglet.window.Window(*WIN) | 1 | 123 | 0 | 0 | 2015-05-02T08:48:00.000 | python,python-3.x,tuples,extract | Python: method to extract tuple | 0 | 1 | 3 | 30,000,302 | 1 |
0 | 0 | My question is simple, apart from the three themes pre-installed in Tkinter are there any other themes I can get ? Something like 3rd party themes ? If not, how can I change the button or other widgets looks (manually changing the form,etc..)?
Also I would like to know if it is possible to change the outside window look, like the look of the
[ _ ] [ [] ] [X]
buttons of the window, if not is there a way to remove them so I can put my own buttons in the frame?
Any code example or link is welcome. | true | 30,002,869 | 1.2 | 0 | 0 | 2 | You cannot change the window border, but you can remove it entirely and draw your own border. You'll also be responsible for adding the ability to move and resize the window. Search this site for "overrideredirect" for lots of questions and answers related to this feature.
As for third party themes: no, there aren't any. | 0 | 174 | 0 | 1 | 2015-05-02T13:29:00.000 | python,python-2.7,tkinter | 3rd party Tkinter themes and modifying outside window buttons | 0 | 1 | 1 | 30,014,871 | 1 |
0 | 0 | I have recently encountered an issue whenever I try and use pygame. The window that comes up hangs and just ends up crashing. I know this program works because I have run it many times before (this also occurs with anything else I try and run in pygame). Strangely, in the command prompt window it asks an input question from a completely unrelated program I was working on last night. | false | 30,089,723 | 0 | 0 | 0 | 0 | It could be, that you named your file pygame.py, so now, whenever you try to import pygame, it imports from THAT pygame.py file. Maybe delete/rename the file and reinstall pygame would work, i had the same problem a year ago and it worked. | 1 | 190 | 0 | 0 | 2015-05-07T00:03:00.000 | python,command-line,pygame | Pygame crashing | 0 | 2 | 2 | 31,355,786 | 1 |
0 | 0 | I have recently encountered an issue whenever I try and use pygame. The window that comes up hangs and just ends up crashing. I know this program works because I have run it many times before (this also occurs with anything else I try and run in pygame). Strangely, in the command prompt window it asks an input question from a completely unrelated program I was working on last night. | false | 30,089,723 | 0 | 0 | 0 | 0 | Seems to be a setup problem.
possible solutions:
rename files (as Mooper suggested)
create the smallest possible use for pygame (once without / once with windows popping up), in order to tell us where the error comes up / does not.
look at the code again; seems to me being an error with a neverending loop / overflowing stack / a function not returning after being called.
last possible idea: reinstall pygame | 1 | 190 | 0 | 0 | 2015-05-07T00:03:00.000 | python,command-line,pygame | Pygame crashing | 0 | 2 | 2 | 41,851,946 | 1 |
0 | 0 | I have been using Python for a bit now (5-6 months) and I would like to finally like to start programming in GUI. Is there a good tutorial for this? Also, I would really like to use something in the default Python language rather than something installed otherwise, unless Py2EXE has been updated to 3.x and it supports other modules (modules? add-ons? I'm trying to say 3rd party GUIs). Thanks!
EDIT: Toolkit? Is that the right word? Also I have used Tkinter and it feels very limited. I could only get buttons to go on the top and it was just weird. Maybe I was doing it wrong. If you have a good tutorial for that, I would greatly appreciate it. | false | 30,111,145 | 0.197375 | 0 | 0 | 1 | Tkinter is part of python, and it is quite powerful. You have Notebook, Listbox and such...
There are some limitations, and PyQt and PyGTK are more powerful.
My advice will be to start with Tkinter (typing what widget you want + tkinter in your search engine usually works) and see what you can do.
I am not sure I understand your comment about buttons, but if you are talking about layout, the grid method of tkinter is very powerful. | 1 | 65 | 0 | 0 | 2015-05-07T20:33:00.000 | user-interface,python-3.x | Integrated GUI for Python3? | 0 | 1 | 1 | 30,111,555 | 1 |
0 | 0 | What I have is a large amount of C code and a bunch of swig wrappers to export all the functions into python. We like using python for testing, it's great, but my problem is there don't seem to be any editors out there that will share tags between python and C.
What I want is to ctrl+click (or whatever shortcut) on a function in a *.py file and have it go to the function definition in a *.c file.
Geany seems to do an alright job of this but it has some limitations (poor gdb support, etc). Eclipse, netbeans, Qt Creator are all good editors for C (creator being my fav) but they don't support cross-language tags. Eclipse in particular supports python quite well in PyDev but a tag in python is totally separate from a tag in C, and I can't seem to find a way to make them share. Vim/emacs probably do due to the somewhat lower level ctags use but I don't like either of them.
Any suggestions? | false | 30,112,333 | 0 | 1 | 0 | 0 | I do this using UltraEdit, but UltraEdit is not great if you do not like it :-) Its not really an IDE more like an Editor. However the way I do it can most likely be ported to e.g. Eclipse.
I generate the Ctags file my self. and force UE to use the custom generated cTags file. This works like a charm. | 0 | 290 | 0 | 5 | 2015-05-07T21:54:00.000 | python,c++,c,exuberant-ctags | Code editor that supports cross-language (c)tags between C and python | 0 | 1 | 1 | 31,437,333 | 1 |
0 | 0 | I am having some Python code that heavily relies on numpy/scipy and scikit-learn. What would be the best way to get it running on an Android device? I have read about a few ways to get Python code running on Android, mostly Pygame and Kivy but I am not sure how this would interact with numpy and scikit-learn.
Or would it be better to consider letting the android application send data to some server where Python is running? | false | 30,119,149 | 0.099668 | 0 | 0 | 1 | Depends on what you need....
Python on a server using Flask/ Django would allow you to build an http UI or even an API interface for your Android (or any) device.
Qpython is a brilliant way to run python on an Android but probably won't cope with the whole of scipy so depends on what libraries have already been ported across by the Qpython team. It's a great tool though and worth a look anyway.
IMHO learning a bit of flask for server side running would be easier and more flexible than using Kivy. | 0 | 2,766 | 0 | 1 | 2015-05-08T08:23:00.000 | android,python,numpy,scikit-learn | Port Python Code to Android | 0 | 1 | 2 | 30,120,067 | 1 |
0 | 0 | I am using Tkinter to create a GUI in python.
What I did was I insert a GIF image into the background and also created labels and buttons.
How do I make the labels and buttons background to be transparent as the background is covering my GIF image? | false | 30,180,138 | 0.379949 | 0 | 0 | 2 | Basically what @Paul Rooney indicated in his comment above.
You might be able to workaround this using canvas to create your own label. You can then use a canvas text object instead of a label.
If you create an empty canvas and add the text with the create_text(), and then place this text-canvas 'on top' of the 'main' canvas, it should simulate what you want. The reason for using two canvases is to prevent scrollability.
I can not think of way to this for buttons though..
Please post your code if you need an example of this :) | 0 | 7,124 | 0 | 0 | 2015-05-12T01:14:00.000 | python,tkinter | How to make labels background to be transparent in Tkinter? | 0 | 1 | 1 | 30,194,049 | 1 |
0 | 0 | I'm trying to create a simple Python application for Linux and I'm using GTK to generate a UI for it. I've only begun exploring GTK but from what I can tell, the moment you call GTK.main() the program goes into that function wherever and only responds to user interactions with the UI. The thing is, I'm running an SDN controller (POX) alongside, and I want the events associated with instances of POX objects to also be able to run (which currently isn't happening since the program gets stuck in 'GTK.main()' forever).
I've considered creating a new thread and calling GTK.main() from there, but then I'll have to worry about thread safety. Isn't there some way where the events for both the UI as well as the objects instantiated in the rest of the program fire alongside? | false | 30,280,774 | 0 | 0 | 0 | 0 | I was able to solve the problem by spawning separate threads for both GTK and the POX controller. With this done, everything's working fine simultaneously. | 0 | 69 | 0 | 0 | 2015-05-16T21:06:00.000 | python,linux,multithreading,gtk,pox | Keep background events active when using GTK | 0 | 1 | 1 | 30,397,459 | 1 |
0 | 0 | I've got my own drawing loaded on to the screen and scaled it to the size I want, but the background of the program I used to make the drawing is still on the image. I noticed that when I move the image, the background doesn't move with the picture, but it actually looks like it's stretching out and it will cover wherever I move the picture to. I think this is because I used the .blit feature when getting my picture on screen, but I can't find a clear enough answer on how to get the picture on screen any other way. Can someone point me in the right direction, please? | true | 30,315,466 | 1.2 | 0 | 0 | 0 | Not sure if this is the problem, but the stretching might be caused by not redrawing the background. Blitting is like painting, you can't erase stuff. When you want to move something, you need to repaint all the places that have changed - also the background that is not visible after movement.
The quickest way to do this is to redraw the whole background. | 0 | 79 | 0 | 0 | 2015-05-19T01:47:00.000 | python,pygame | Getting my drawing into pygame without .blit() | 0 | 1 | 2 | 30,315,673 | 1 |
0 | 0 | How can I register a callback for when a Kivy gui is loaded?
In my Kivy app, as soon as the GUI is loaded (aka the window pops up with the initial view), I need to kick off a function that loads expensive data and updates the UI.
So far i've been using the on_start method in App but this runs before the GUI is loaded.
essentially, i want something like $( document ).ready() (from jquery) but for ivy | false | 30,332,159 | 0 | 0 | 0 | 0 | You could Clock.schedule(some_function, 0) in your build method, I think that would run after everything is initialised but before the next frame. | 0 | 499 | 0 | 2 | 2015-05-19T17:21:00.000 | python,kivy | kivy -- event for when guis is loaded | 0 | 1 | 1 | 30,334,720 | 1 |
0 | 0 | Is it possible to use any Python package within a Kivy program, and ultimately running it on an android device? for example - can I use the package "xlrd" or "googlemaps" on Kivy? If the answer is positive, How do I do it? normally I get an error message that says "No module named X".
Thank you. | true | 30,353,541 | 1.2 | 0 | 0 | 1 | Yes you can. Just download the package you want to use and place it in the same folder as your main.py. Then import whatever you wish to use from that package. The packages will also work when you deploy the app onto an Android device. | 0 | 199 | 0 | 1 | 2015-05-20T15:04:00.000 | python,packages,kivy | Using various Python packages within a Kivy program | 0 | 1 | 1 | 30,354,153 | 1 |
0 | 0 | I am building a turn-based strategy game using Libtcod and Python. The game map has variable terrain and each tile can be 1 of 5 types:
Plains - Costs 1 to move over
Forest - Costs 2
River - Costs 4
Hill - Costs 3
Mountain - Impassable
Each type has its own movement cost, so that it costs less "move points" to move through plains than through a forest, for example. I want to display all the squares a unit can move to given its movement range/starting move points.
Libtcod has pathfinding functionality built for both A* and Dijtskra and it is trivial to display all the squares in a given range, without accounting for terrain.
However, I cannot figure out how I can implement the terrain costs, without having to write my own pathfinding algorithm. Looking at the docs I know it has something to do with:
def path_func(xFrom,yFrom,xTo,yTo,userData) : ...
path_new_using_function(width, height, path_func, user_data=0, diagonalCost=1.41)
dijkstra_new_using_function(width, height, path_func, user_data=0, diagonalCost=1.41)
but I cannot figure out what the custom function is supposed to do. According to the docs, it supposed to
...return the walk cost from coordinates xFrom,yFrom to coordinates
xTo,yTo. The cost must be > 0.0f if the cell xTo,yTo is walkable. It
must be equal to 0.0f if it's not.
but, isn't that the point of the dijtskra algorithm to begin with? That is, the algorithm is supposed to take into account the variable costs of each tile and then build a path accordingly.
The map itself already has the terrain and move costs applied to it, I just need a way to bridge that data with the pathfinding. | false | 30,408,098 | 0 | 0 | 0 | 0 | As far as I understand, what you want to achieve is very well possible with tcod's built-in pathfinding function.
path_new_using_function will call your path_func with adjacent cells, so you can simply have it return the values you listed above depending on the terrain below (xFrom, yFrom) and/or (xTo, yTo). | 0 | 965 | 0 | 2 | 2015-05-23T01:50:00.000 | python,algorithm,dijkstra,libtcod | Python Libtcod: How to do pathfinding with variable move cost terrain? | 0 | 1 | 2 | 54,982,870 | 1 |
0 | 0 | Making a very simple tic-tac-toe game in Python using a P2P architecture with sockets. Currently my GUI has button that says 'Create' that will open up and draw a new game board window, create a socket, bind, listen, and accept a connection. The 'Join' button will open and draw a new gameboard and connect to that 'server'.
I'm trying to have it show a message saying 'Waiting for player...' when you create a game, a cancel button to stop and go back to the main menu, and have it disappear on it's own if a connection has been accepted.
I tried using tkMessageBox but the script stops until the user clears the message so there's no way for me to listen/accept until the user presses something.
What other way is there for me to accomplish this?
Thanks! | true | 30,430,162 | 1.2 | 0 | 0 | 1 | Sounds like a threading issue.
I'm unfamiliar with TK graphics, but I'd imagine what you need to do is start the window showing the "waiting for player" message. That window then loops waiting for something to happen.
When the message box displays you need to have the "listening" done on another thread, which signals back to the main message box when someone's connected using a semaphore or a queue.
On your main GUI thread you need to make the loop:
check the queue or semaphore for values. If there's a value on there that you expect, close the box. This would need to be non-blocking so that the GUI thread can still check for input from the user.
check for user input. That's probably done using callback functions though. | 0 | 339 | 0 | 4 | 2015-05-25T01:35:00.000 | python,sockets,p2p | Python: Show message 'Waiting for player...' while socket listens for connection | 1 | 1 | 1 | 30,430,588 | 1 |
0 | 0 | I am learning python and i don't know that it will be helpful to me if i want to make android apps.I have read somewhere that python can make android app.But I want to ask you that is it a good option or we should always use andriod studio to make android apps because that is developed particularly for creating android apps. | false | 30,465,364 | 0.066568 | 0 | 0 | 2 | If the question is,can i run python programs on android then by all means yes.
But if the intent is to create a mobile app usibg python then please look at kivy which is yet to support python 3.
But outside the love of python ,its best to stick to android studio for native android apps. | 0 | 25,019 | 0 | 9 | 2015-05-26T17:42:00.000 | android,python,android-developer-api | Can python build android apps? | 0 | 2 | 6 | 30,466,179 | 1 |
0 | 0 | I am learning python and i don't know that it will be helpful to me if i want to make android apps.I have read somewhere that python can make android app.But I want to ask you that is it a good option or we should always use andriod studio to make android apps because that is developed particularly for creating android apps. | false | 30,465,364 | 0 | 0 | 0 | 0 | Yes you can using
1- Kivy library
2- install Ubuntu on a versatile machine
3- run buildozer to transfer your main.py file into APK file | 0 | 25,019 | 0 | 9 | 2015-05-26T17:42:00.000 | android,python,android-developer-api | Can python build android apps? | 0 | 2 | 6 | 68,053,648 | 1 |
0 | 0 | My setting: Python 2.7 with anaconda
Recently I have installed OpenCV 3.0 and when I try to do simple image display or I want to run python samples that come with OpenCV, there is a error message:
This application failed to start because it could not find or load the Qt platform plugin "xcb".
I have read many comments that I need to attach .so files to my project but I don't think it's the optimal solution since for most people it works out of a box.
I have no clue what to do. I'm inexperienced. What comes to my mind is only to reinstall everything. | false | 30,483,753 | 0.197375 | 0 | 0 | 2 | Okey, I have figured it out.
During cmake I set flag -D WITH_QT=OFF since I read somewhere that it doesnt work for Qt5.x | 0 | 1,947 | 0 | 1 | 2015-05-27T13:21:00.000 | python,opencv,anaconda,xcb | python app - xcb plugin fail | 0 | 1 | 2 | 30,487,195 | 1 |
0 | 0 | I have a program in which I use a tkinter button to exit the program with the exit() command. However, when I compile the program through cx_freeze, it doesn't work anymore. I also tried with sys.exit() but then the button doesn't work at all (with or without cx_freeze). Any hint would be appreciated, thanks! | true | 30,490,795 | 1.2 | 0 | 0 | 2 | For tkinter applications, the preferred way to exit is name_of_application.destroy(). Using exit() can give unpredictable results. | 0 | 628 | 0 | 3 | 2015-05-27T18:50:00.000 | python,python-3.x,tkinter,cx-freeze | exit() doesn't work with cx_freeze | 0 | 1 | 1 | 30,491,828 | 1 |
0 | 0 | I'm experiencing something strange when using Image.resize(). I have two images, one is a cropped version of the other. I've been working out the aspect ratio so that I can resize both images by the same factor and then resizing them separately.
Now for some reason, the larger of the two images is resized fine but the cropped version has some colour distortion. It almost appears like the image has been slightly saturated.
Has anyone experienced this before or know why it might be happening?
Thanks for reading. | false | 30,540,872 | 0.066568 | 0 | 0 | 1 | I haven't used Pillow, and I haven't seen your images or code, but let's say you have an image with a resolution of 400x200 and you want to resize it to 200x100, then each of the new pixels needs to have some color. Since the new image is smaller, the colors from the original will have to be mashed together to form the new colors. So, in this case where it gets smaller by a factor of two in each dimension, the color of each pixel will be the average of four pixels from the original. Similarly, if you resize to a larger image, depending on how that is done, the new pixels could be blocky (like when you zoom in to any pixel image) or smooth, which would mean that they are some interpolation of the pixels from the original image. | 0 | 1,342 | 0 | 0 | 2015-05-30T00:16:00.000 | python,image,pillow | Using Python to resize images using Pillow, why are the colours changing? | 0 | 1 | 3 | 30,541,163 | 1 |
0 | 0 | I have been working on my first wxpython app and this app has a search functionality. The app has to search for elements from database, list them and display details of one single element, when the element is clicked from the list.
I found there is ListView or ObjectListView to be used for this. But what should be used so that on click of a single element in that list, I should display the panel which displays the dynamic data for that particular element? | false | 30,545,494 | 0 | 0 | 0 | 0 | I found out that wx has a EVT_LIST_ITEM_ACTIVATED event that is triggered when a list item is double clicked. I used this to capture the selected item and display the data accordingly. | 0 | 33 | 0 | 0 | 2015-05-30T11:18:00.000 | python,wxpython | Display single element page on click of list element wxpython | 0 | 1 | 1 | 30,546,887 | 1 |
0 | 0 | I got program that draws spaceship
(Turtle Graphics) forward,backward etc.
By using a lot of orders and lines drawing spaceship takes 5 seconds using turtle.speed(0).
And whenever you click the right/left key it draws it again in other direction.
It major thing in my project.
Is there a way to draw it faster?
Thanks in advance. | true | 30,554,696 | 1.2 | 0 | 0 | 2 | By default, turtle has a draw delay of 10 milliseconds. Every time it updates the canvas, it will pause 10 milliseconds as a simple way of controlling the animation speed. This delay is independent of the speed of the turtle itself. If you want to speed up the animation, you can set a shorter delay, e.g. with turtle.delay(3) or turtle.delay(0).
Note that turtle graphics are more of an educational tool than a serious way to do graphics. If you don't have a specific reason to use turtle, consider switching to other graphics libraries. | 0 | 1,123 | 0 | 3 | 2015-05-31T06:53:00.000 | python,python-2.7,turtle-graphics | Faster drawing in python | 0 | 2 | 2 | 30,554,792 | 1 |
0 | 0 | I got program that draws spaceship
(Turtle Graphics) forward,backward etc.
By using a lot of orders and lines drawing spaceship takes 5 seconds using turtle.speed(0).
And whenever you click the right/left key it draws it again in other direction.
It major thing in my project.
Is there a way to draw it faster?
Thanks in advance. | false | 30,554,696 | 0.099668 | 0 | 0 | 1 | you can use screen.tracer(n) where a bigger n value means a faster drawing speed but less details | 0 | 1,123 | 0 | 3 | 2015-05-31T06:53:00.000 | python,python-2.7,turtle-graphics | Faster drawing in python | 0 | 2 | 2 | 30,555,631 | 1 |
0 | 0 | I'm working on developing a PyQt4 application that will require a lot of widgets and I have run into an issue. When you say where to move the widget to (such as: btn.move(100, 100) it moves it properly, but if you resize the window, you can't see it). I'm not sure how to fix this. I don't want to restrict resizing of the window from the user, but I can't have widgets not showing up on screen.
So if the user resizes the program window to 600x600, how can I have widgets automatically change their location? | false | 30,560,147 | 0 | 0 | 0 | 0 | Use a Qt layout (like a QVBoxLayout, QHBoxLayout, or a QGridLayout) | 0 | 42 | 0 | 0 | 2015-05-31T17:05:00.000 | python,widget,pyqt,pyqt4 | How to update PyQt4 widget locations based on window size? | 0 | 1 | 1 | 30,563,200 | 1 |
0 | 0 | I am writing a Kivy UI for cmd line utility I have developed. Everything works fine, but some of the processes can take from a few seconds to a few minutes to process and I would like to provide some indication to the user that the process is running. Ideally, this would be in the form of a spinning wheel or loading bar or something, but even if I could update my display to show the user that a process is running, it would be better than what I have now.
Currently, the user presses a button in the main UI. This brings up a popup that verifies some key information with the user, and if they are happy with those options, they press a 'run' button. I have tried opening a new popup to tell them that the process is running, but because the display doesn't update until the process finishes, this doesn't work.
I have a lot of coding experience, but mostly in the context of math and engineering, so I am very new to the designing of UIs and having to handle events and threads. A simple self-contained example would be greatly appreciated. | false | 30,595,908 | 0.066568 | 0 | 0 | 1 | I've dealt with similar problem and creating new thread didn't do the trick. I had to use Clock.schedule_once(new_func) function. It schedules function call to the next frame, so it is going to run almost immediately after callback ends. | 0 | 12,311 | 0 | 9 | 2015-06-02T12:20:00.000 | python,user-interface,events,kivy | Building a simple progress bar or loading animation in Kivy? | 0 | 1 | 3 | 56,684,592 | 1 |
0 | 0 | I'm wondering if there are any preloaded gestures on kivy, such as pinch, expand, etc. The examples have check, square, circle, and cross gestures. Is there a database for more? | false | 30,645,470 | 0 | 0 | 0 | 0 | I'm not sure that there is, not many people use the gestures. We have a gsoc project that will probably bring some improved tools for this to kivy core, though. | 0 | 63 | 0 | 0 | 2015-06-04T13:43:00.000 | python,kivy,gesture | Preloaded gestures on Kivy? | 0 | 1 | 1 | 30,648,659 | 1 |
0 | 0 | I'm adding a simple toolbar to my PyQt application and trying to get the toolbar to start by default in the top position, but in the 2nd row beneath another toolbar.
I have called:
self.addToolBar(Qt.TopToolBarArea, navBar)
This combines the toolbar with my first toolbar which is much shorter into the same row. Is there a way to force these toolbars to be in separate rows? | false | 30,687,178 | 0.379949 | 0 | 0 | 2 | Finally found the solution after scouring the documentation and trying different options. I think I was looking for something along the lines of "toolBarRow" so I missed it.
The solution is to insert a toolBarBreak. The same way a separator can be added to a toolbar itself, a "break" simply breaks up one of the four areas provided for tool bars: either top, bottom, left, or right. It is added with similar functions to the way separators are added to toolbars, with:
QMainWindow.addToolBarBreak() which adds to the "end" of the toolbar area, which really means the most inward position.
or
QMainWindow.insertToolBarBreak(toolBarBefore) which adds right before the passed in toolbar reference. | 0 | 714 | 0 | 1 | 2015-06-06T20:17:00.000 | python,pyqt | PyQt toolbar in 2nd row by default | 0 | 1 | 1 | 30,687,563 | 1 |
0 | 0 | I am using the anaconda python distribution (python version 2.7) and I would like to be able to use wxpython either in a notebook or at least in an ipython console through the anaconda spyder app (their IDE). I am running into what is apparently a common problem which is due to the anaconda python environment not being recognized as a framework with GUI access.
In fact, I am able to launch a wxpython app when working directly in ipython when launched from the command line. However, when trying to get an app to run from either the spyder IDE ipython console or an ipython notebook I get this error:
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
If anyone knows a workaround for this I would very much appreciate your advice.
Thanks! | false | 30,743,683 | 0 | 0 | 0 | 0 | I believe simply using pythonw vs. python helped when I was using a MacBook. | 1 | 2,244 | 0 | 0 | 2015-06-09T22:08:00.000 | python,wxpython,anaconda | How to use wxpython in an ipython notebook or console | 0 | 2 | 2 | 36,034,036 | 1 |
0 | 0 | I am using the anaconda python distribution (python version 2.7) and I would like to be able to use wxpython either in a notebook or at least in an ipython console through the anaconda spyder app (their IDE). I am running into what is apparently a common problem which is due to the anaconda python environment not being recognized as a framework with GUI access.
In fact, I am able to launch a wxpython app when working directly in ipython when launched from the command line. However, when trying to get an app to run from either the spyder IDE ipython console or an ipython notebook I get this error:
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
If anyone knows a workaround for this I would very much appreciate your advice.
Thanks! | false | 30,743,683 | 0 | 0 | 0 | 0 | In an ipython notebook before you run a cell invoking wxpython functions you have to insert the %gui magic:
%gui wx | 1 | 2,244 | 0 | 0 | 2015-06-09T22:08:00.000 | python,wxpython,anaconda | How to use wxpython in an ipython notebook or console | 0 | 2 | 2 | 30,744,213 | 1 |
0 | 0 | I know there are many posts about this problem (i've read them all).
But i still have a problem with my exe, still cannot be opened.
I've tried to put the qwindows.dll (i tried with 3 different qwindows.dll) in the folder dist with my exe but doesn't change anyhting.
I've tried with libEGL.dll, nothing.
Any suggestions ? Is there a way to avoid having this problem ? | true | 30,757,708 | 1.2 | 0 | 0 | 3 | I've had this issue aswell, after a lot of digging I found the following solution:
Copy the following file next to you main .exe:
libEGL.dll
Copy the following file in a folder "platforms" next to you main .exe:
qwindows.dll
Putting the qwindows.dll in the subfolder is the important part I think, hope this helps | 0 | 1,637 | 0 | 1 | 2015-06-10T13:24:00.000 | python,user-interface,py2exe,pyqt5 | Qt platform plugin 'windows' - py2exe | 0 | 2 | 3 | 31,620,544 | 1 |
0 | 0 | I know there are many posts about this problem (i've read them all).
But i still have a problem with my exe, still cannot be opened.
I've tried to put the qwindows.dll (i tried with 3 different qwindows.dll) in the folder dist with my exe but doesn't change anyhting.
I've tried with libEGL.dll, nothing.
Any suggestions ? Is there a way to avoid having this problem ? | false | 30,757,708 | 0 | 0 | 0 | 0 | For me it was enough to copy qwindows.dll to platforms folder, like @Inktvisje wrote.
And don't repeat my mistake: don't download this dll from Internet! Copy it from your Python libs folder: YourPythonFolder\Lib\site-packages\PyQt5\plugins\platforms. | 0 | 1,637 | 0 | 1 | 2015-06-10T13:24:00.000 | python,user-interface,py2exe,pyqt5 | Qt platform plugin 'windows' - py2exe | 0 | 2 | 3 | 41,159,237 | 1 |
0 | 0 | I have a python program using PySide. When run normally, it opens up a PySide GUI, but when run with some flags in the command line, it spits some things out in the console window.
I'd like to retain this dual functionality, but it seems with py2exe you have to choose whether to have a console window or not when compiling, with no option for choosing during program execution.
Is what I want to do possible with py2exe, or even with some other python "compiler?" | false | 30,759,749 | 0.197375 | 0 | 0 | 1 | This is not a py2exe limitation, but a Windows limitation. On Windows, applications are compiled either as Console Applications or GUI Applications. The difference is that Console Applications always open a console window, whilst GUI Applications never do.
As far as I can tell, it's not possible to have an application with dual functionality. As a workaround, I suggest that you simply compile two executables: one for console use and one for GUI use. | 1 | 66 | 1 | 0 | 2015-06-10T14:45:00.000 | python,user-interface,console,pyside,py2exe | py2exe: Allow a console window to be either shown or hidden with a sys.argv | 0 | 1 | 1 | 30,759,966 | 1 |
0 | 0 | I'm confused as to the difference between using a function in commands of tkinter items. say I have self.mb_BO.add_radiobutton(label= "Red", variable=self.BO, value=2, command=self.red)
what is the difference in how the add statement works from this:
self.mb_BO.add_radiobutton(label= "Red", variable=self.BO, value=2, command=self.red())
where func red(self) changes the color to red.
And self.mb_BO.add_radiobutton(label= "Red", variable=self.BO, value=2, command=lambda: self.red())
Essentially I don't understand what these commands are doing and when to use the callback or function reference. I've spent hours looking online for an easy to follow summary to no avail and I am still just as confused. | true | 30,769,851 | 1.2 | 0 | 0 | 2 | A good way to look at it is to imagine the button or binding asking you the question "what command should I call when the button is clicked?". If you give it something like self.red(), you aren't telling it what command to run, you're actually running the command. Instead, you have to give it the name (or more accurately, a reference) of a function.
I recommend this rule of thumb: never use lambda. Like all good rules of thumb, it only applies for as long as you have to ask the question. Once you understand why you should avoid lambda, it's OK to use it whenever it makes sense. | 0 | 881 | 0 | 1 | 2015-06-11T00:59:00.000 | python,lambda,tkinter,command | commands in tkinter when to use lambda and callbacks | 0 | 1 | 2 | 30,770,368 | 1 |
0 | 0 | I know the difference between static and dynamic linking in C or C++. But what does it mean in Python? Since it's just an interpreter, and only having one style of import mechanism of modules, how does this make sense?
If I freeze my Python application with cx_freeze by excluding a specific library, is it a kind of dynamic linking? Because, users have to download and install that library by themselves in order to run my application.
Actually my problem is, I'm using the PySide library (with LGPL v2.1) to develop a Python GUI application. The library says I should dynamically link to the library to obey their legal terms (same as Qt). In this case, how do I link to PySide dynamically? | true | 30,770,219 | 1.2 | 0 | 0 | 1 | In python there's no static linking. All the imports requires the correct dependencies to be installed on our target machine. The choice of the version of such libraries are in our decision.
Now let's come to the binary builders for python. In this case, we'll have to determine the linking type based on the GNU definitions. If the user can replace the dependency as he likes, it's dynamic. If the dependency is attached together with the binary itself, it's static linking. In case of cx_freeze or pyinstaller, if we build this as one file, it's static linking. If we build this in normal mode where all the dependencies are collected as separate files, it's dynamic linking. Idea is, whether we can replace the dependency in target machine or not. | 1 | 2,509 | 0 | 12 | 2015-06-11T01:45:00.000 | python,qt,pyside,cx-freeze | What does it mean for statically linking and dynamically linking in Python? | 0 | 1 | 1 | 43,317,798 | 1 |
0 | 0 | Using PyQt 4, Python 2.7, Windows 7 on a x64 machine.
I have been developing a bit of code using a Python console with PyQt4 and passing strings from QLineEdit() widgets to OS commands with no issues using os.system(cmd)
But when I tried running from the command line in Windows I get the following error,
TypeError: sequence item 0: expected string, QString found
I got around this by converting the offending string via str(cmd) but it has left me curious about, why this should happen only when the code is called from the command line and not when called within a Python console? | false | 30,833,264 | -0.099668 | 0 | 0 | -1 | I think that this problem happens because the command line parameters are actually byte arrays and not strings, strings are encoded in Unicode, but byte arrays are not. Calling str(cmd) return the content of cmd as a string. | 0 | 288 | 0 | 1 | 2015-06-14T18:54:00.000 | python,windows,command-line,pyqt4,qstring | PyQt Qstring not accepted when script run from WIndows command line, why? | 0 | 1 | 2 | 30,833,435 | 1 |
0 | 0 | I'm using PyQt4 to enter credentials into a domain login page and pull data from several additional pages in the domain. Everything works exactly as expected when supplying login or search credentials from within the code. When I open up raw_input to allow the user to enter information, it causes hang-ups trying to download one of the web-pages. I can't provide information on the page itself because it is on a corporate network, but it doesn't make sense that simply using raw_input would cause problems with QWebpage loads.
The QNetworkManager throws 1 of the expected 3 or 4 .finished signals and the QWebpage frame never throws the .loadfinished signal so it just hangs.
(I've tried to flushing stdin as well as seek(0) which gives me a bad file descriptor error). Has anyone run into such a problem before? | true | 30,926,097 | 1.2 | 0 | 0 | 1 | raw_input uses synchronous/blocking IO without giving Qt a chance to continue processing events in the background. Qt isn't really prepared for it's processing to be halted in this way. In theory it should just resume when raw_input is finished. But maybe in the meantime a timeout occurred or something like that. You really should use signal/event based input when using Qt.
If GUI interaction is ok you should try QInputDialog::getText because it looks like a blocking call from the outside but internally lets Qt to continue processing background jobs. | 0 | 285 | 0 | 1 | 2015-06-18T21:27:00.000 | python,pyqt4,stdin,raw-input,qwebpage | Using raw_input causes problems with PyQt page loading | 1 | 1 | 1 | 30,926,485 | 1 |
0 | 0 | I'm using Tkinter to design a UI for an application. I'm using grid geometry and while specifying button width (or any widget width), I realized that width should be specified in text units and not pixels. Since I want to make it platform independent and screen size independent Is there any method to get max text unit width ? So that I can do math on basis of that.
For example:
I've 10 buttons in a row, which should be of equal width. If I hard code a width value specific to current screen value, it would not work on diff screen wise.
Thanks. | true | 30,950,925 | 1.2 | 0 | 0 | 8 | If you want to make a GUI that is "platform independent and screen size independent", you definitely do not want to be measuring sizes yourself. Unless, by saying you want something platform independent, you're saying you want a button to be X pixels regardless of pixel density or screen resolution (which seems like a very bad idea).
The whole reason tkinter supports measuring in character units, along with options for widgets to stretch and shrink, is to support platform independence. When you start working at the pixel level, you will have many, many problems when you run the code on other platforms, or on other displays, or with other fonts.
That being said, the measure method of a font can tell you exactly how many pixels a given string will require in a given font. If you want to know how wide "one character" is, you can use the measure method on the string "0", which is what tkinter uses as a base when computing widths based on characters.
If you want buttons to be exactly the same size, using character widths will give you that, because it isn't the width of 10 actual characters in that widget, but ten average character widths. In that case, "10 characters" will be the same for every widget, no matter what the contents of that widget. | 0 | 10,473 | 0 | 2 | 2015-06-20T06:13:00.000 | python,tkinter | Tkinter : Getting screen text unit width. (Not pixels) | 0 | 1 | 3 | 30,954,325 | 1 |
0 | 0 | I need to execute C++ code to acquire images to process in python.
I need to use these commands from python:
make and
./name_of_the_executable
Could anybody please help know me how to do it? | false | 30,954,589 | 0.197375 | 0 | 0 | 2 | Look For python.net which is cable of making a call to the interfaces written in .net supported languages.
What all you need to do is
Steps:
Download and put it two files Python.Runtime.dll and clr.pyd in your DLLs folder.
From you >>>(triple greater than prompt )Python prompt Try
>>>import clr
if it doesn't gives any error you are good to go .
Next You need to do is put Your C++ Dll inside Lib/site-packages Folder .
(This is not mandatory but good for beginners).
Next to import clr try importing your Dll as a module import YourDllName
If step 5 doesn't gives you a error . Hola You are done That's All Folks :) | 1 | 70 | 1 | 0 | 2015-06-20T13:36:00.000 | python,c++ | Excuting cpp file from Python | 0 | 1 | 2 | 30,954,837 | 1 |
0 | 0 | I am currently trying to write a script to automate the ATTO disk benchmark GUI. I can use the script to successfully locate images in the GUI, but I can not get any clicks generated by the script to register in the application. I have modified the script to test if I could use the PyAutoGUI package to click things in other applications, and have been able to successfully click things in other applications. Has anyone else had this issue with other applications using the PyAutoGUI package, and if so did you ever find any solution to the issue? | false | 30,991,451 | 0.197375 | 0 | 0 | 1 | Please try to run your script with administrative privileges. If you are using Powershell then run powershell as administrator | 0 | 1,086 | 0 | 0 | 2015-06-22T23:18:00.000 | python,user-interface,automation | PyAutoGUI click() function will not register in certain applications | 0 | 1 | 1 | 34,939,080 | 1 |
0 | 0 | I am interested into programming with different languages besides Ti-Basic (like Java, C, and Python) on my Ti-84 plus calculator. Does my calculator support this, and if not, are there any calculators on the market that would be able to do this? Thanks in advance!
(The idea is that when I don't have access to my computer at home, I could just pull out my pocket calculator and start programming and testing out some algorithms on the go that come in mind.)
It doesn't have to be a calculator, just something cheap and programmable and something I can carry around in my hand. | false | 30,993,221 | 0.049958 | 1 | 0 | 1 | You would need a compiler that will translate whatever language you're writing in (in the case of Java, an implementation of the JVM as well) to the assembly used by the calculator's CPU, it's probably not likely you will find an easy to use solution as calculators like the TI-84 are pretty archaic. | 1 | 3,809 | 0 | 6 | 2015-06-23T03:13:00.000 | java,python,c,calculator,ti-basic | Multiple Language Programming on Ti-Calculator | 0 | 3 | 4 | 30,993,515 | 1 |
0 | 0 | I am interested into programming with different languages besides Ti-Basic (like Java, C, and Python) on my Ti-84 plus calculator. Does my calculator support this, and if not, are there any calculators on the market that would be able to do this? Thanks in advance!
(The idea is that when I don't have access to my computer at home, I could just pull out my pocket calculator and start programming and testing out some algorithms on the go that come in mind.)
It doesn't have to be a calculator, just something cheap and programmable and something I can carry around in my hand. | false | 30,993,221 | 0.049958 | 1 | 0 | 1 | The TI-84 Plus CE Python allows you to code in Python but it is a barebones implementation. But it has been pretty useful for me. | 1 | 3,809 | 0 | 6 | 2015-06-23T03:13:00.000 | java,python,c,calculator,ti-basic | Multiple Language Programming on Ti-Calculator | 0 | 3 | 4 | 69,366,466 | 1 |
0 | 0 | I am interested into programming with different languages besides Ti-Basic (like Java, C, and Python) on my Ti-84 plus calculator. Does my calculator support this, and if not, are there any calculators on the market that would be able to do this? Thanks in advance!
(The idea is that when I don't have access to my computer at home, I could just pull out my pocket calculator and start programming and testing out some algorithms on the go that come in mind.)
It doesn't have to be a calculator, just something cheap and programmable and something I can carry around in my hand. | true | 30,993,221 | 1.2 | 1 | 0 | 3 | After a little research, I found some some hand-held "pocket" devices.
The Palm m500 has a JVM to program java on. There apparently was a website that had an SDK for C, but the website was removed.
In regards to calculators:
TI-82, 83, 84, 85, 86, and related models all support TI-BASIC and z80 ASM.
TI-92, Voyage 200, TI-89, and related models all support TI-BASIC, C, and 68000 ASM.
TI-nspire supports TI-BASIC and Lua.
HP 50g supports RPL (User and System), ARM ASM, Saturn ASM, and C.
HP 49, 48G, or 48S, which support Saturn ASM and RPL. | 1 | 3,809 | 0 | 6 | 2015-06-23T03:13:00.000 | java,python,c,calculator,ti-basic | Multiple Language Programming on Ti-Calculator | 0 | 3 | 4 | 31,085,450 | 1 |
0 | 0 | I would like to move the cursor in a Python matplotlib window by a (data) pixel at a time (I'm displaying a 2D image), using the keyboard arrow keys. I can trap the keyboard keypress events, but how do I reposition the cursor based on these events? | false | 31,003,551 | 0 | 0 | 0 | 0 | One solution is to make MatPlotLib react to key events immediately.
Another solution is print a 'Cursor' or marker line on the plot, and change its coordinates with the mouse events. Eg. draw a vertical line, and update its X coordinates with the left and right keys. You can then add a label with the X coordinate along the line, and other nice tricks. | 0 | 533 | 0 | 1 | 2015-06-23T13:02:00.000 | python,matplotlib | move cursor in matplotlib window with keyboard stroke | 0 | 1 | 2 | 31,004,307 | 1 |
0 | 0 | I am trying to get my game to look/scale well across different devices. I am attempting to introduce the dp and sp metrics into my apps as much as possible, but in this case I am refactoring a game to use these metrics for layout and widget sizing.
Where before, my layouts were sized using size_hint in order to have everything get it's size relative to it's parent(the app itself is not given a size, nor is the window, but the root widget/layout has size_hint=(1, 1)), I am now faced with replacing this system with dp values, and can't figure out what they should be.
I am thinking, that if I just size the root widget, App itself, or Window with dp, then I could continue to use size_hinting, as this would have a trickle down effect and scale everything correctly from the top on down, so to speak. And for this, It seemed like getting the resolution or density of a devices screen would be a great help(so I could use it to size my root widget/App/Window, per device). Is that possible with Kivy? Will this work? Is there a better way? What would you do? Thanks | false | 31,037,748 | 0.379949 | 0 | 0 | 2 | Using size_hint alone already guarantees a degree of scale independence, as (as you note) all the sizes will be relative.
Kivy internally checks some resolution related values of the device, and this is basically the point of dp; something like dp(10) for instance should be the same actual size on any device, in terms of real size on the screen in e.g. centimetres. This won't actually be quite right, if nothing else I think devices don't report precisely right results, but unless this is very important it will already take care of making things mostly look the same anywhere.
I'm not sure what you mean about setting the App size - in Android's window manager an App just fills the screen (at least in most cases). | 0 | 766 | 0 | 1 | 2015-06-24T21:51:00.000 | android,python,scale,kivy,screen-density | Proper usage of metrics with Kivy(So GUI scales well across devices) | 0 | 1 | 1 | 31,038,234 | 1 |
0 | 0 | I am new to python and want to learn this from the basic.
I want to open two other application like notepad in a single window. I searched for any examples by using "tkinter". Any idea for implementing this using "tkinter".
PS: two tabs one in left and one in right so that one tab will be having notepad and other will have a media player (let say) and i should be able to close the single parent window for closing this child windows. | false | 31,098,786 | 0 | 0 | 0 | 0 | I don't think you will be able to do this easily. Notepad is using its own toolkit which, most probably, is not compatible with the one you are using.
If you want to open eg. an editor, look for a widget in the toolkit of your choice which does what you want (or nearly). Eg. if you want an editor, use the GtkTextView in GTK, or, if you want something that can do code editing, look at GtkSourceView, etc. Same goes for media applications.
The 'include' applications as part of a project works only to a certain point. You can eg, include text-mode applications in a terminal window, but graphical apps are much harder. | 1 | 509 | 0 | 0 | 2015-06-28T10:33:00.000 | python,window,parent | Opening other application in single window using python | 0 | 2 | 3 | 31,100,428 | 1 |
0 | 0 | I am new to python and want to learn this from the basic.
I want to open two other application like notepad in a single window. I searched for any examples by using "tkinter". Any idea for implementing this using "tkinter".
PS: two tabs one in left and one in right so that one tab will be having notepad and other will have a media player (let say) and i should be able to close the single parent window for closing this child windows. | false | 31,098,786 | -0.066568 | 0 | 0 | -1 | For what you need, you will have to use libraries like tkinter or pyqt. As you want to learn it from the basic, I would suggest you to pick a GUI library and start learning it. Eventually you will know how to get the result that you desire. | 1 | 509 | 0 | 0 | 2015-06-28T10:33:00.000 | python,window,parent | Opening other application in single window using python | 0 | 2 | 3 | 31,098,854 | 1 |
0 | 0 | I am trying to make a Drop Down Menu of colors. Red Green Blue Yellow. I want the words inside the option box to be colored with their respected name. So the when the user clicks the arrow to open the optionMenu, Option red will have red letters. blue will have blue letters and so forth.
Is this Possible?
Thanks. | false | 31,105,836 | 0 | 0 | 0 | 0 | Try using the fg(or foreground) and bg(or background) options. If a is the menu, use:
a.entryconfig( optionindex , bg=" color_name " ) for the background, and
a.entryconfig( optionindex , bg= " color_name " ) for the foreground. | 1 | 439 | 0 | 1 | 2015-06-28T23:24:00.000 | python,tkinter,optionmenu | How do you change the color of the words in a Python Tkinter OptionMenu | 0 | 1 | 2 | 31,127,939 | 1 |
0 | 0 | In the program I'm writing, the user needs to be able to select a cell in the grid and edit its value. The program also shows what the value of the currently selected value is in hexadecimal (so (0,0) is 0x00, (1,3) is 0x19, etc.) I originally had this display be updated through a binding to the wx.grd.EVT_GRID_SELECT_CELL event. However, upon doing this, the GridCursor would no longer move, it would stay on (0,0). So, I added a SetGridCursor statement to the handler to have it move the cursor when the handler was called. However, this generated an infinite loop, as apparently SetGridCursor generates an EVT_GRID_SELECT_CELL command when called.
My question is, how do I have code that executes when a new cell is selected while still maintaining the old cell selection functionality? | true | 31,118,668 | 1.2 | 0 | 0 | 0 | Adding event.Skip() at the end of my custom handler passes the event to the default handler. | 0 | 137 | 0 | 0 | 2015-06-29T14:44:00.000 | python,events,grid,wxpython,wxwidgets | In wxPython Grid, creating event handler for Cell Selection disables moving the GridCursor | 0 | 1 | 1 | 31,124,993 | 1 |
0 | 0 | I'm wondering if python is a good choice to develop a desktop application for a small business.
Is it possible to build something using PyQT or even Swing + Jython ? How I can make a executable file at the end? | false | 31,123,293 | 0 | 0 | 0 | 0 | It depends on what you are looking to do. I have done it and it worked but there are other questions that can factor in like who will maintain or update the code, and do they know Python. You can look at cx_freeze for making a windows executable out of a python program as one of many options. | 1 | 2,859 | 0 | 0 | 2015-06-29T18:50:00.000 | python,pyqt | Is python a good choice to build a desktop application? | 0 | 2 | 2 | 31,123,417 | 1 |
0 | 0 | I'm wondering if python is a good choice to develop a desktop application for a small business.
Is it possible to build something using PyQT or even Swing + Jython ? How I can make a executable file at the end? | true | 31,123,293 | 1.2 | 0 | 0 | 8 | I've found Python to be an excellent choice for developing a broad scala of applications including desktop applications. I've developed in C++ for many years, and for parts that are really time critical I sometimes use it still, but for most of my code Python helps me get results much faster. There are several ways to get an executable. Py2exe is one of them, Cython another option allowing easy combination with C++ if you need raw speed, interfacing with 3rd party libaries or low level control of devices. It also makes reverse engineering a bit harder, if that's a concern in your project.
By the way, when I started out with Python I was very concerned about performance and (being a quality manager at that time) almost blocked its introducion in our company for its lack of strickt typing. I was wrong about both. Since especially the rich set of built in datastructures as well as many of its standard modules are written in C++ and have been carefully optimized, it isn't so easy to beat on speed and memory efficiency as one might think. And the dynamic typing (only recently introduced in a language like C#) proved a very powerful means to write concise, readable, reliable and compact code.
I don't have shares (since Python is open source anyhow) but from all the languages I've used in the past (Algol, Pascal, Modula II, Assembler, Basic, Fortran, Cobol, C, C++, C#, Java, JavaScript) it's the one I prefer rightnow to earn a living with. | 1 | 2,859 | 0 | 0 | 2015-06-29T18:50:00.000 | python,pyqt | Is python a good choice to build a desktop application? | 0 | 2 | 2 | 31,123,686 | 1 |
0 | 0 | I'm creating a setup.py install script for my upcoming PyQt application. The PyQt modules are all spelled with camel case as opposed to the standard module name conventions, and I can't find what name to use in the setup script.
What is the name of the PyQt4 module to be used in the install_requires field of setup()? | false | 31,167,283 | 0 | 0 | 0 | 0 | A search of the Python Package Index reveals it's actually python-qt. Annoying, but I suppose it works.
EDIT: Actually, it's not. See the comments below. | 1 | 432 | 0 | 1 | 2015-07-01T16:50:00.000 | python,dependencies,pyqt4,setuptools,setup.py | PyQt4 as dependency in setup script | 0 | 1 | 1 | 31,167,583 | 1 |
0 | 0 | I'd like to import the "requests" library into my Kivy application. How do I go about that? Simply giving import requests is not working out.
Edit:
I'm using Kivy on Mac OS X, 10.10.3. | false | 31,182,671 | 0.099668 | 0 | 0 | 1 | If you're using windows with kivy's portable package, I think you can get a shell with kivy's env by running the kivy executable. Assuming so, I think you can run pip install requests in this shell to install it to kivy's environment.
Edit: I see you've now noted you are using OS X, but something similar may be true. I don't know about this though. | 0 | 1,389 | 0 | 2 | 2015-07-02T10:57:00.000 | python,kivy | Importing libraries in Kivy | 1 | 1 | 2 | 31,183,217 | 1 |
0 | 0 | This question is distilled from the original application involving callback functions for Tkinter buttons. This is one line that illustrates the behavior.
lambdas = [lambda: i for i in range(3)]
if you then try invoking the lambda functions generated:
lambdas[0](), lambdas[1]() and lambdas[2]() all return 2.
The desired behavior was to have lambdas[0]() return 0, lambdas[1]() return 1, lambdas[2])() return 2.
I see that the index variable is interpreted by reference. The question is how to rephrase to have it treated by value. | false | 31,186,959 | -0.099668 | 0 | 0 | -2 | Ahhh, further Googling found a solution (admittedly one I would not have stumbled upon myself). The desired behavior can be invoked by use of a default argument:
lambdas = [lambda i=i: i for i in range(3)] | 1 | 1,153 | 0 | 4 | 2015-07-02T14:13:00.000 | python,python-2.7,lambda,list-comprehension | How to generate a list of different lambda functions with list comprehension? | 0 | 1 | 4 | 31,187,126 | 1 |
0 | 0 | I have a C# Application and I want to run python script by passing some arguments and i also want to return some values from python. should i make a .dll file of my python script ? or is there any other way.
I can't use ironpython because i am unable to import my python project libraries in ironpython
thanks | false | 31,211,941 | 0.099668 | 1 | 0 | 1 | Convert your Python script to executable using py2exe.exe, and call it from C# using Process.
Another way is to execute cmd command "python program.py" from your C# program. But, you've to make sure that environment variable for Python is set. | 1 | 339 | 0 | 2 | 2015-07-03T17:37:00.000 | c#,python | Executing Python Script from C# (ironPython is not an option) | 0 | 1 | 2 | 31,212,458 | 1 |
0 | 0 | I have a design question. I'm doing an exercise in python (2.7) which is a simple game with a labyrinth. I need to read an write from a specific file every step of the game.
Currently I have 2 classes (Game and Labyrinth). The Labyrinth class is responsible for reading and writing the file.
My question is, is it ok to open the file in the init function of Labyrinth and close it at the end of the game within another function (which can be called from another class)? Or is it better to open and close the file every time?
The reason I don't save the file content into a string with readlines() is because I'm supposed to save to the file each step of the game. | true | 31,243,476 | 1.2 | 0 | 0 | 1 | You are at the design phase.
So, you have to weigh the chances of losing your data due to some error or crash against the importance of your data and the cost of "protecting" it.
Using with protects you from some errors. If you consider that python itself may crash (e.g.), then you still have some risk. Saving after each step is evidently safer. How useful it is depends on the volume of saved data (and there are techniques for reducing this as well), the impact of each save on performance, and the chances of such crashes.
Without any further info, and simply guessing, my answer to your specific question:
... is it ok to open the file in the init function of Labyrinth and
close it at the end of the game...? Or is it better to open and close
the file every time?
is that I would save after each step. | 1 | 62 | 0 | 1 | 2015-07-06T10:27:00.000 | python,file,oop | Working with files in an object | 0 | 1 | 2 | 31,244,797 | 1 |
0 | 0 | I'm trying to count the number of distinct colors in an image using img.getcolors(). However, this does not distinguish between transparent and black pixels - they both report as one pixel colored [0,0,0].
How can I distinguish between transparent and black pixels? Many of the images I need to process are largely black on a transparent background.
For test purposes, I'm using a PNG I created which is half transparent, half black. len(img.getcolors()) is 1. | false | 31,279,936 | 0 | 0 | 0 | 0 | Embarrassing answer:
I was using convert('RGB') before calling getcolors(). Without the conversion, a 4-value tuple comes back with an alpha channel. | 0 | 421 | 0 | 0 | 2015-07-07T21:49:00.000 | python,png,python-imaging-library,transparent | PIL Image.getcolors() cannot distinguish between black and transparent? | 0 | 1 | 1 | 31,280,044 | 1 |
0 | 0 | I have code in python that integrates c++ code using swig.
The c++ class has a field with the long value 1393685280 which is converted to python.
The problem is that when calling the getter of this field from python I get the int value -2901282016 instead.
How can I fix it?
Thanks | false | 31,314,526 | 0 | 1 | 0 | 0 | Well, sorry to give everyone the run-around on this one.
We found the solution and it's completely unrelated to SWIG.
Problem emanated from the ODBC driver for the Vertica DB we were using which behaved unpredictably when using a long variable to bind the SQL result to.
Tomer and Inbal | 0 | 103 | 0 | 0 | 2015-07-09T10:15:00.000 | python,type-conversion,swig | swig converts a positive long to negative int | 0 | 1 | 1 | 31,378,499 | 1 |