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 | I have heard of Python's GIL problem, which states that there can only be one Python thread executing the Python bytecode at one time in a multicore machine. So a multithreaded Python program is not a good idea.
I am wondering if I can write a C extension that uses pthread to potentially boost the performance of my program. I'd like to create a thread in my C extension and make it runs in parallel with Python's main thread.
My assumption is that the Python main thread will do things more related to IO, while the pthread in my C extension will spend most of its time doing computation. The Python main thread communicates with the thread in the C extension using a queue (like a producer consumer model).
Is there any difference between multithread with Python and C extension? | false | 12,635,762 | 0.066568 | 0 | 0 | 1 | The Python interpreter is not aware of C launched threads in any way, so they can happily churn their own CPU time.
However I doubt this is a correct solution for your performance problems. First try using multiple processes with multiprocess module. If interprocess IO is too much after that you can result trickery like C threads. This would make your program an order of magnitude more complex so avoid it if possible. | 1 | 1,191 | 0 | 7 | 2012-09-28T07:45:00.000 | python,multithreading,gil | Could a C extension for multithreaded Python boost performance? | 0 | 3 | 3 | 12,636,228 | 1 |
0 | 0 | I have heard of Python's GIL problem, which states that there can only be one Python thread executing the Python bytecode at one time in a multicore machine. So a multithreaded Python program is not a good idea.
I am wondering if I can write a C extension that uses pthread to potentially boost the performance of my program. I'd like to create a thread in my C extension and make it runs in parallel with Python's main thread.
My assumption is that the Python main thread will do things more related to IO, while the pthread in my C extension will spend most of its time doing computation. The Python main thread communicates with the thread in the C extension using a queue (like a producer consumer model).
Is there any difference between multithread with Python and C extension? | true | 12,635,762 | 1.2 | 0 | 0 | 2 | To answer your original question:
Yes, C extensions can be immune from the GIL, provided they do not call any Python API functions without the GIL held. So, if you need to communicate with the Python app, you'd need to acquire the GIL to do so. If you don't want to get your hands too dirty with the C API, you can use ctypes to call a C library (which can just use pthreads as usual), or Cython to write your C extension in a Python-like syntax. | 1 | 1,191 | 0 | 7 | 2012-09-28T07:45:00.000 | python,multithreading,gil | Could a C extension for multithreaded Python boost performance? | 0 | 3 | 3 | 12,636,279 | 1 |
0 | 0 | I have heard of Python's GIL problem, which states that there can only be one Python thread executing the Python bytecode at one time in a multicore machine. So a multithreaded Python program is not a good idea.
I am wondering if I can write a C extension that uses pthread to potentially boost the performance of my program. I'd like to create a thread in my C extension and make it runs in parallel with Python's main thread.
My assumption is that the Python main thread will do things more related to IO, while the pthread in my C extension will spend most of its time doing computation. The Python main thread communicates with the thread in the C extension using a queue (like a producer consumer model).
Is there any difference between multithread with Python and C extension? | false | 12,635,762 | 0 | 0 | 0 | 0 | Provided one thread runs CPU bound while the other runs IO bound, I don't see a problem.
The IO bound thread will call IO routines which usually release the GIL while doing their stuff, effectively allowing the other thread to run.
So give the "simple" solution a try and switch only if it really doesn't work the way you want it to. | 1 | 1,191 | 0 | 7 | 2012-09-28T07:45:00.000 | python,multithreading,gil | Could a C extension for multithreaded Python boost performance? | 0 | 3 | 3 | 12,636,431 | 1 |
0 | 0 | I am designing a Copy/Paste Application for Windows os using Python.Now I want to a Register my application with hotkey for "Ctrl+V" So that when any one press "Ctrl+V" Paste is done through my application and not through windows default Copy/Paste application.But I don't know how to get the list of files path which are to be copied and also the path of Target window where paste is to be done.So I want to know what actually happens when someone presses Ctrl+C key in windows explorer | true | 12,659,719 | 1.2 | 0 | 0 | 4 | When someone presses the Ctrl+C key in Explorer, Explorer calls OleSetClipboard() with an IDataObject containing various formats, which may include CF_FILES, CFSTR_FILECONTENTS and CFSTR_SHELLIDLIST. | 0 | 339 | 0 | 1 | 2012-09-30T08:08:00.000 | python,windows,winapi,python-2.7,pywin32 | Windows:What actually happens when Ctrl+C is pressed in windows explorer | 0 | 1 | 1 | 12,659,846 | 1 |
0 | 0 | My question is about the easiness of distributing the GUI app across the platforms (Mac/Linux/Windows), and I want to know the one that makes the user's job easiest.
My current understanding is that Tkinter app is the easiest for the users (to install) because as long as the user has installed a Python in her box, my application should be ready to run on that box.
For GUI app written in wxPython or pyQT, the user needs to install wxWidget or QT in her box first, which is an extra step, and then install my GUI app. (But my Ubuntu box seems to have the wxWidget libraries and QT libraries installed by default, is that a norm or just Ubuntu distro is more friendly to users? I guess Windows and Mac probably does not provide them by defualt, ie. the users need to download and install them as an extra step) | true | 12,666,278 | 1.2 | 0 | 0 | 8 | If you're running Ubuntu, PyQt will be installed by default. Most linux distros will have one of PyGtk or PyQt installed by default. WxPython was most likely installed in your Ubuntu box as a dependency for some other package in your system.
If your target market is Linux, you can just create a deb or rpm package and that'll take care of the dependencies for your application.
For Windows and Mac(and even Linux if you're so inclined) you could bundle the python interpreter with your application and its libraries into a native executable format such
as .exe, .dmg or .elf using libraries like cx_freeze, py2exe and py2app. Once this is done, your user will not have to install python or any of your libraries. | 0 | 4,379 | 0 | 8 | 2012-10-01T00:22:00.000 | python,user-interface,wxpython,pyqt,tkinter | Python GUI App Distribution: written in wxPython, TKinter or QT | 0 | 2 | 3 | 12,667,986 | 1 |
0 | 0 | My question is about the easiness of distributing the GUI app across the platforms (Mac/Linux/Windows), and I want to know the one that makes the user's job easiest.
My current understanding is that Tkinter app is the easiest for the users (to install) because as long as the user has installed a Python in her box, my application should be ready to run on that box.
For GUI app written in wxPython or pyQT, the user needs to install wxWidget or QT in her box first, which is an extra step, and then install my GUI app. (But my Ubuntu box seems to have the wxWidget libraries and QT libraries installed by default, is that a norm or just Ubuntu distro is more friendly to users? I guess Windows and Mac probably does not provide them by defualt, ie. the users need to download and install them as an extra step) | false | 12,666,278 | 0.26052 | 0 | 0 | 4 | Tkinter is the only one that's included with Python. wxPython and pyQT need both the wxWindows or QT libraries and the wxPython or pyQT libraries to be installed on the system.
However, Tk does not look very nice. If you're already making the user install Python, you could just as well have them install the libraries too. (Or maybe include an installer or something.) | 0 | 4,379 | 0 | 8 | 2012-10-01T00:22:00.000 | python,user-interface,wxpython,pyqt,tkinter | Python GUI App Distribution: written in wxPython, TKinter or QT | 0 | 2 | 3 | 12,666,368 | 1 |
0 | 0 | Simple question. I'd like to use F2 or Enter for rename, and double click to open a file.
Using self.treeView.doubleClicked.connect(self.doubleclick) I can do things in my self.doubleClick method, but the renaming is still triggered.
The model is not read-only (model.setReadOnly(False)). | false | 12,670,874 | 1 | 0 | 0 | 9 | I don't know if you have this in python versions, but in C++ Qt you just set the edit triggers in the QAbstractItemView:
void setEditTriggers ( EditTriggers triggers ) | 0 | 3,516 | 0 | 4 | 2012-10-01T09:45:00.000 | python,pyqt,double-click,qtreeview,qfilesystemmodel | How to disable the double click file renaming behavior on QTreeView and QFileSystemModel in PyQt? | 0 | 1 | 2 | 15,352,784 | 1 |
0 | 0 | Ok, I am new to python and my code calls some library (which is wrapping some C++ code) and I pass it a callback function on my side (as library needs to). The strange thing is that if I insert a breakpoint in my other part of the code, it will hit and deugger stops in eclipse but none of my breakpoints in the callback hit. The callback is sure called but the breakpoint is somehow ignored by PyDev. What I am doing wrong? The callback is obviously coming on a different thread. I am using Python 2.7 | true | 12,718,216 | 1.2 | 0 | 0 | 1 | Try importing pdb and just manually setting breakpoints in the code with pdb.set_trace(). This won't work in all multi-threaded cases, but I find that it works in many of them and is a big improvement over the native Eclipse/PyDev debugger. | 1 | 736 | 0 | 1 | 2012-10-03T23:16:00.000 | python | In Pydev setting a breakpoint, but breakpoint not hit on callbacks only | 0 | 1 | 1 | 12,727,999 | 1 |
0 | 0 | I want to use ironpython inside my C# App, but I am afraid that it will cause a security issue, I don't want the end user to use all the available DLLs of my App, instead I want to provide custom classes that user can use in python.
My question is how to secure my dlls from being used in ironpython.
the end user may addReference of the dll, I want to secure most of the classes from being used. | false | 12,721,998 | 0 | 0 | 0 | 0 | The trick is to run IronPython in its own AppDomain and only provide the assemblies you want the user to be able to call to that AppDomain, and then set the security policy to prevent them from referencing more. | 1 | 97 | 0 | 0 | 2012-10-04T07:09:00.000 | c#,security,ironpython | Secure and protect classes or DLLs in .NET from being used in IronPython | 0 | 1 | 1 | 12,730,482 | 1 |
0 | 0 | I see that all tutorials about the pyopengl implements pygame, is posible use PyOpengl without pygame?. and if is so, then, is most faster without pygame or not? | false | 12,737,366 | 0 | 0 | 0 | 0 | PyGame's only relation to PyOpenGL is that PyGame can provide a window for PyOpenGL to render on.
Your question now is whether PyGame's windowing environment is faster than another.
In my experience, GLUT can be very slightly faster than PyGame for windowing (by comparing GLUT and SDL). wxWidgets I think is a bit slower. PyGlet isn't PyOpenGL (although it is a Python OpenGL implementation).
My recommendation: PyGame is easiest to use and provides helpful utilities besides. Use it instead of anything else; any performance differences are negligible.
When you need better windowing support, go for Qt or wxWidgets, in that order. | 0 | 1,388 | 0 | 3 | 2012-10-04T23:17:00.000 | python-3.x,pygame,pyopengl | PyOpengl without PyGame | 0 | 1 | 2 | 12,755,970 | 1 |
1 | 0 | I am trying to make a android apps using Dojo toolkit and GeoDjango. Its a project based on GPS work. Can anyone help in this issue? I want to have the staring steps? I have some source code and SDK installed in my computer. But still confused about the staring. can Anyone help?
How I will make it possible to create the apps. Steps plz? | true | 12,750,731 | 1.2 | 0 | 0 | 0 | I suggest to take a look at PhoneGap. I use it to embed JQuery mobile inside a Android application. PhoneGap makes it easy to embed javascript inside an Android application. Just try the PhoneGap tutorial.
Edit: PhoneGap let u use the GPS sensor through javascript | 0 | 197 | 0 | 1 | 2012-10-05T16:53:00.000 | android,python,django,dojo | Android apps with Dojo and geodjango | 0 | 1 | 1 | 12,750,812 | 1 |
0 | 0 | I'm writing a 2D Elite-style game in Python+Pygame, and I need to move the starmap about so the player can look at the whole thing.
The way I've done this sort of thing before is to just add the coordinates of the 'camera' to the coordinates of everything else when drawing. However, I notice Pygame has a function to move the entirety of a surface some amount. Would this be a quicker, easier way to implement this functionality?
The starmap is about 100,000 pixels square, if it depends on the size of the image. | true | 12,767,315 | 1.2 | 0 | 0 | 0 | Well for starters, one huge bitmap is not really good, since it eats away resources.
What I do, is divide the map into size of camera, and end up with having 9 tiles displayed at a time, moving the camera shifts the map, and draws only the ones that are seen.
There isn't a huge improvement though.
You can always try the easier approach, and if you feel that the game is too slow, you can try another.
There is no point of optimizing if you can't see the difference. | 0 | 676 | 0 | 2 | 2012-10-07T08:39:00.000 | python,optimization,graphics,pygame | Is Surface.scroll() the right way to implement a movable 2D viewpoint in Pygame? | 0 | 1 | 1 | 12,767,902 | 1 |
0 | 0 | I have a poorly designed and big (> 300 public functions, >200 numeric constants defined with #define in the header file) that I have to wrap in Python. I have the dll and the h file. The library is updated yearly, till now in a backwards compatible way (i.e. just functions were added, a constant keep their numerical values, etc). But I have no guarantees as I do not control the library.
Using ctypes, I see two ways of wrapping this in Python:
Mapping every constant and function to python, 1 to 1
Redefining the API in Python and making calls to the library.
The first can be done in a (roughly) automatic way from the header file and therefore is easier to maintain and upgrade, the second requires a lot of python code but it will be easier to use.
I would appreciate some opinions based on your experience with this type of problem and some examples. | false | 12,770,077 | 0 | 0 | 0 | 0 | Maintaining a Python library with a ctypes backend isn't an unmanageable approach. Obviously the initial investment is larger than using automated tools, but the API you are left with should be much better.
If you do take that route, aim to separate the Python API entirely from the C library though. Supporting multiple ctypes backends with one Python front end api isn't too bad - just query at runtime and dynamically load the correct ctypes wrapper module. I've done that to wrap different dll files and .so files for windows and linux but it would work for versions of a library as well. | 1 | 249 | 0 | 7 | 2012-10-07T15:21:00.000 | python,dll,wrapper,ctypes | Maintainability of a python wrapping of a C library | 0 | 1 | 2 | 12,996,919 | 1 |
0 | 0 | I recently discovered how easy and convenient using wxPython is for writing GUI applications. Unfortunately installing wxPython is a giant throbbing pain in the neck. I consider myself pretty tech-savvy but it took me almost an hour to get a working setup of wxPython on a Pythonbrew install on an Ubuntu machine. On my OSX machine at home I still haven't figured it out.
So my question is; is it possible, somehow, to install a portable version of wxPython and place it in my project directory where it will work on all platforms, saving users the pain of having to manually install it to run my application? If yes, how would I go about it? | true | 12,788,394 | 1.2 | 0 | 0 | 1 | wx has to be compiled for each target plattform. Binaries are always OS dependent, so no, there cannot be a portable wx version. | 0 | 298 | 0 | 1 | 2012-10-08T19:44:00.000 | python,wxpython | Can I embed wxPython in my project, saving users the trouble of installing it? | 0 | 1 | 2 | 12,788,472 | 1 |
0 | 0 | Is there any way to disable the editing of specific cells by the user when using ListCtrl with TextEditMixin?
I guess there's some way that Vetos the editing event, however I can't find it. | false | 12,806,542 | 0.066568 | 0 | 0 | 1 | As I recall, you have to bind to EVT_LIST_BEGIN_LABEL_EDIT. Then in your event handler you just check what column you're in and if you're in a column that you want to be editable, then you do "event.Allow()", otherwise you veto. | 0 | 2,303 | 0 | 7 | 2012-10-09T18:53:00.000 | python,listview,wxpython | wx.ListCtrl with TextEditMixin - Disable Editing of Selected Cells | 0 | 2 | 3 | 12,807,804 | 1 |
0 | 0 | Is there any way to disable the editing of specific cells by the user when using ListCtrl with TextEditMixin?
I guess there's some way that Vetos the editing event, however I can't find it. | false | 12,806,542 | 0.132549 | 0 | 0 | 2 | In wxPython version 4.0.0 the line:
if event.m_col == 1
does not work. Use
if event.GetColumn() == 1
instead. | 0 | 2,303 | 0 | 7 | 2012-10-09T18:53:00.000 | python,listview,wxpython | wx.ListCtrl with TextEditMixin - Disable Editing of Selected Cells | 0 | 2 | 3 | 45,455,459 | 1 |
0 | 0 | I am using GtkMenuToolButton and it has a button and a menu. When you click on the arrow the menu is opened. I'd like to make the button open that same menu as well. Simply emitting "show-menu" in the "clicked" callback did not work. Please help how to make this work. | false | 12,818,397 | 0.099668 | 0 | 0 | 1 | I have currently ended up doing this:
Instead of GtkMenuToolButton I have GtkToolItem with custom content
In custom content I have GtkMenuButton
Inside that one, I delete the default GtkArrow and replace it with 1x2 GtkGrid which has a Label + GtkArrow
As a whole it does what I want =) | 0 | 213 | 0 | 1 | 2012-10-10T11:35:00.000 | python,gtk | How to make GtkMenuToolButton open the same menu when 'clicked' signal is emitted? | 0 | 1 | 2 | 12,827,853 | 1 |
0 | 0 | I am having some issues making 'bigger than simple scripts and stuff' applications in Python. I have a class called WinMain, a class called Engine, one called State and another called Element. It's laid out like this:
WinMain is the main class of the program, it has a mainLoop function and various other things.
Engine is an object that contains data like images and rendering code.
State is an object held by Engine that has its update method called each time Engine's step function is called.
Elements are objects held by State that are things like gui buttons and pictures to render.
Since my rendering functions are in Engine, how will I get my Elements (held by state) to render things? I suppose I could give each Element the instance of Engine, but that seems to be kind of hacky, because I'd have to do stuff like this:
picture = Element(engine, (0, 0), 'gui_image') (not good)
I'd rather do picture = Element((0, 0), 'gui_image') and still some how let the Element render things using Engine.
This seems to be a major structural problem I have with most projects I start, and I can't seem to find a way around it (other than passing a honkload of variables through the arguments of classes and functions). How might I do this? | true | 12,848,684 | 1.2 | 0 | 0 | 4 | Engine is an object that contains data like images and rendering code
This sounds like a God class: they're common in GUI code, and the problem you're having is a common effect of that.
What is the conceptual relationship between different stuff in Engine? Does it need to be tightly coupled, or could the Engine just coordinate between the State, a Renderer and some other stuff?
However that bit breaks down, passing the Engine (or Renderer, or whatever) down through the state machine is the only way to avoid a global (or singleton) with your current architecture.
The usual way to break this dependency is to use something like an MVC (Model/View/Controller) pattern. Specifically, it sounds like the Engine is already roughly a Controller, and the State and Elements have the Model part covered. However, the Engine, State and Elements are also handling the rendering/presentation part: this introduces the coupling.
If you can find a way to publish the State changes to some observer (deliberately leaving that vague, because we don't want the State logic to depend too much on the details of the observer), you can make a Renderer listen to State (model) updates and draw them. Now, the observer can be anything you want, so it's easy to mock, and it's also decoupled from the Engine. | 0 | 467 | 0 | 3 | 2012-10-11T21:19:00.000 | python,oop,structure | Python structural issue: Giving an 'engine' class to everything | 0 | 1 | 3 | 12,849,650 | 1 |
0 | 0 | I'm trying to create a simple read/write application for a fairly simple USB device, but it's turning out to be not so simple at all.
I'm using WinUSB and SetupAPI DLLs and working from scratch since I can't seem to find anything that actually works for what I need. PyWinUSB and PyUSB and so on and so forth came close, but when I tried actually writing to the device with them they failed.
Anyway, right now I'm still at about ground zero. Following the instructions, I'm calling the SetupDiGetClassDevsExW function from the SetupAPI.dll. The function executes correctly as indicated by a call to the kernel32.lasterror function returning zero, but the only thing I'm getting back from the call is an integer value. Is that correct? Is this even the correct function? (There are 4 that are similar, and there is no just plain SetupDiGetClassDevs function. The 4 functions are SetupGetClassDevsExW, SetupGetCLassDevsExA, SetupGetClassDevsA, and SetupGetClassDevsW.) Do I need to create a class to work with this? I ask because calling the next function, SetupDiEnumDeviceInterfaces, has only been returning a fail with code 259, which means ERROR_NO_MORE_ITEMS according to a quick google search.
I've made some headway in that someone has showed me the correct class structure method for creating a structure for holding some information, but being that I've never actually worked with programming for a USB device before, let alone in Python, I'm still kind of stuck. I'll provide any more information that is needed for an answer, but right now I don't want to bog this Q/A down with needless information.
Thanks. | false | 12,852,084 | 0 | 0 | 0 | 0 | There is a SetupDiGetClassDevsA and SetupDiGetClassDevsW. The Ex versions allow connecting to a remote machine. The A version takes a byte string for the second parameter, while the W version takes a Unicode string. The return value is a handle to a device information set.
The device information set has to be iterated with either SetupDiEnumDeviceInfo or SetupDiEnumDeviceInterfaces. The second function only works if you pass DIGCF_DEVICEINTERFACE as a flag to SetupDiGetClassDevs and pass an interface GUID for the ClassGuid parameter; otherwise, you pass a device class GUID and only SetupDiEnumDeviceInfo will return anything. | 0 | 1,154 | 0 | 0 | 2012-10-12T04:06:00.000 | python-2.7,ctypes,windows-7-x64,setupapi,pywinusb | Calling SetupDiGetClassDevs from Python only returns an integer value | 0 | 1 | 1 | 12,862,740 | 1 |
0 | 0 | I'm looking for a framework to write a GUI in python, the GUI will also include 3D graphics. I would like the development time to be really short, and the framework easy to get started with.
What do you recommend?
I'm considering PyQt but it doesn't seems to have good 3D support.
Another alternative would be a browser GUI, with WebGL, and have python on the backend. I think this will be really slow because I'm working with a lot of big photos. | false | 12,853,267 | 0.197375 | 0 | 0 | 1 | In our company we have been working with the combination, Python, PyQt and OpenGL. It has not been super easy to integrate, but it was the best solution we found around 4 years ago. | 0 | 1,682 | 0 | 0 | 2012-10-12T06:13:00.000 | python,user-interface,3d | 3D & GUI for python | 0 | 1 | 1 | 12,854,078 | 1 |
0 | 0 | I am writing a Tkinter App which does some long running operation. In order to prevent Tkinter window from hanging, i am introducing threading :- one thread for performing long running operation, second thread will be for updating GUI based on the QUEUE which will be filled by long running operation. Now I am thinking of running Tkinter mainloop in a separate thread instead of main thread, reason being is I want to update the state of GUI (Configure some buttons), only once the long running thread is complete. If I run the Tkinter mainloop in main thread, it won't wait for long running thread to complete and will update the GUI before it. So is it safe if i run Tkinter main loop in separate thread and in main loop wait for long running thread to complete before other updates? Any other ideas for this problem? | true | 12,861,495 | 1.2 | 0 | 0 | 1 | It is my understanding that tk needs to be run in the main thread. | 1 | 688 | 0 | 0 | 2012-10-12T14:43:00.000 | python,tkinter | Python Tkinter in thread or in main app? | 0 | 1 | 1 | 12,863,076 | 1 |
0 | 0 | I am attempting to teach myself python and have hit a rough spot once it has come to recursion. I have done the classic recursive functions (factorial, fibonacci numbers...) but I am going back over old code and trying to convert most of my iterative functions to recursive functions for practice.
This is the wall that I have hit:
I made a dungeon crawler a while back and I am trying to replace a for loop I used to reveal the squares near my sprite. So when the sprite is placed, he/she sees the tile he/she is on as well as the adjacent and diagonal squares (9 in total including the one the avatar is on).The other tiles making up the room are hidden. This I deemed view radius 1. For view radius 2, I wanted the char to see radius 1 squares plus all the tiles adjacent to those tiles. At the time I could not figure out how to do it with a for loop so I just implemented a simpler scheme.
I feel this visibility function could be written recursively but I am having a hard time coming up with a base case and what my recursive step would be. My for loop just took avatar pos and iterated over a range to avatar pos + radius and I did that for the x,y coordinates.
As far as translating this over to a recursive function I am really confused. I have done many searches trying to get a lead but only come up with complicated subjects such as: FOV using recursive shadowcasting which is way beyond me.
Any help would be greatly appreciated. | false | 12,867,465 | 0.099668 | 0 | 0 | 1 | I find it helps a LOT to express recursions in words. What the algorithm says is basically "what's visible at radius N is what's visible from radius N-1". Like, uh, the edge gets bigger. | 1 | 241 | 0 | 0 | 2012-10-12T21:38:00.000 | python,recursion | Recursive Function To Help Clear Tiles (Field Of View) | 0 | 1 | 2 | 12,869,565 | 1 |
0 | 0 | I know FUSE has bindings for C, C++, Python etc. Which effectively means that I can develop FUSE filesystems using those languages.
I wish to use Cython, as it offers much faster speeds as compared to pure Python. That is stressed in a filesystem. Is it possible to produce a FUSE filesystem by coding in Cython?
As far as I understand, Python documentation is all that I require to write Cython code for FUSE. But (if it is indeed possible) should I be using Cython as a Python FUSE system or C system?? | false | 12,875,660 | 0 | 0 | 0 | 0 | You should use it as a Python Fuse System, then you can write your cython stuff in it's own module and just import that module in your python code. Usually file system related operations are IO bound and not CPU bound so I'm not sure how much of a speedup you would get with cython, but I guess try out and compare the results. | 1 | 173 | 1 | 0 | 2012-10-13T18:18:00.000 | python,c,cython,fuse | can I use FUSE with Cython bindings | 0 | 1 | 1 | 12,875,850 | 1 |
0 | 0 | Is it possible to control the position of elements in a wx.MenuBar()? I can't find it in the docs, but it seems like it should be an option. By default, menu elements, like file, view, edit, etc.. are at the left most position, and then each additional element extends to the right. I have a very simple gui, and thus only have one menu element called help. I'd like to position it RIGHT, instead of the default LEFT. | false | 12,878,695 | 0.197375 | 0 | 0 | 2 | Really you have methods to place menu to position that you want:
Append(menu, title)
Add menu to the end of MenuBar (i.e. place it as most right element). title is a title of a new menu. If succed returns True, otherwise - False.
Insert(pos, menu, title)
Insert menu in pos position (after that GetMenu(pos)==menu will be True). All menu in position after that will be shifted right. pos=0 is firts (left) position. if pos=GetMenuCount(), the result will be like by using Append(). title is a title of a new menu. If succed returns True, otherwise - False.
Remove(pos)
Remove menu from position pos, all menu in position after that are shifted to the left. Returns deleted menu.
Replace(pos, menu, title)
Replace menu in position pos and don't affect to other menus in MenuBar. Returns menu that was in that position.
Sorry for my English) | 0 | 231 | 0 | 0 | 2012-10-14T02:02:00.000 | python,wxpython | Is there a position the menu elements of a wx MenuBar? | 0 | 1 | 2 | 12,884,118 | 1 |
0 | 0 | I wrote my program to spawn a process of the main application. When I run the pyinstaller packaged exe it says no Module name pygame.base. But if I keep the app in the main thread it doesn't do that.
I need the process to detect closure, because GLUT doesn't have an event for the upper right hand exit button and I can't remove it unless I use full-screen. The program's threads hang and the app never closes. So the main thread checks to see if the process is running. If not, it closes the entire application. But all closure will hang if I only use the main thread.
I can soft exit from in-game events just fine. But I need a way to catch the X button. OR fix pyinstaller.
I've looked up a bunch of things getting pyinstaller to include everything. I used the OneDir option so I can see the files. I copied all dependencies from one that worked to the one that didn't without replacing the exe. It still had the import error.
Any insight would be nice. For now the X button is a hazard. I'm guessing multiprocessing doesn't work with pyinstaller all too well. | false | 12,880,380 | 0 | 0 | 0 | 0 | The [x] button fires for me, when event.type == pygame.QUIT on windows. | 1 | 751 | 0 | 2 | 2012-10-14T08:05:00.000 | python,opengl,multiprocessing,pygame,pyinstaller | No Module name pygame.base | 0 | 1 | 1 | 12,885,990 | 1 |
0 | 0 | I'm considering creating a wxPython application that I'll deploy for Windows and OSX. I want to include Flash objects like YouTube embeds and Twitch.tv embeds in the application. Is that possible? Are there any resources out there that addresses the issue? | true | 12,892,263 | 1.2 | 0 | 0 | 1 | You can try the WebView widget that was mentioned or download the separate webkit port and try that (search the wxPython mailing list for a link to that). Otherwise, the only truly supported wxPython widget that does this is "ActiveX_FlashWindow" and I'm pretty sure that's Windows-only. | 0 | 146 | 0 | 0 | 2012-10-15T08:59:00.000 | python,flash,wxpython | Can I create a cross-platform wxPython application that uses Flash embeds? | 0 | 1 | 1 | 12,896,608 | 1 |
0 | 0 | i'm using IronPython and i want to create some windows form,
i want to create a windows form with some button, and i want to do this in visual studio with iron python,
i'm using visual studio 2012 integrated edition,
each time i create an "ironpython windows form" project, when i want to run it, it says:
The project is currently set to use the .NET debugger for IronPython
debugging but the project is configured to start with a CPython
interpreter. To fix this change the debugger type in project
properties->Debug->Launch mode
when i change debugger to Standard Python Launcher, it says:
ImportError: No module named clr
what should i do? | false | 12,906,249 | 1 | 0 | 0 | 6 | I got the same error and resolved it with these steps:
I changed the project properties
General>Interpreter to IronPython 2.7
Debug>Launch mode to IronPython(.NET) launcher
At first I didn't see IronPython as an interpreter option to select from. I added the path to IronPython installation to my Path System variable, restarted Visual Studio and it worked. | 1 | 4,656 | 0 | 5 | 2012-10-16T01:15:00.000 | python,clr,visual-studio-2012,ironpython | Cpython interpretter / IronPython interpretter No module named clr | 0 | 1 | 3 | 13,183,325 | 1 |
0 | 0 | I'm trying to make a simple piano keyboard for my programming class. I've made it in pygame because it's nice and simple to use. I've managed to get it working by making a mouse rect and individual rects for each note on the piano and having the note play by linking it to a mousebuttondown event. So it's working pretty good but I'll be demonstrating it on a smartboard and I was wondering if I could make it multiplayer. The problem is I can't work out a way that two people can play at the same time because obviously there's only one mouse (which is detected by the player tapping on screen) and therefore one mouse.get_pos() for the rect collision detection. If anyone can suggest a work around that'd be cool!
Thanks for the help
-Laura | false | 12,939,379 | 0.099668 | 0 | 0 | 1 | The MOUSEBUTTONDOWN event has two attributes:
pos
button
If you use event.pos instead of mouse.get_pos() you should be able to pick up the coordinates where the click occurred even if you have more than one mouse. | 0 | 880 | 0 | 0 | 2012-10-17T16:53:00.000 | python,mouse,pygame | Multiple mouse position | 0 | 1 | 2 | 12,940,103 | 1 |
0 | 0 | I am creating CFUNCTYPE objects in my script and passing them as callbacks to c.
If I make them local they are destroyed immediately and I am getting access violaton errors
Tried to gc.disable(), it doesnt help.
Today Im making global lists and putting/removing FUNCTYPE objects when needed.
Is there better solution? | true | 12,995,925 | 1.2 | 0 | 0 | 1 | The easiest way is to attach the CFUNCTYPE objects to a module or class. I've found it useful to have a Python wrapper module - in essence a separate file that keeps everything at the ctypes level in one namespace.
You could add and remove your callbacks from there as necessary. | 1 | 265 | 0 | 1 | 2012-10-21T07:40:00.000 | python,ctypes | How to prevent FUNCTYPE from being collected | 0 | 1 | 2 | 12,996,825 | 1 |
0 | 0 | What is the class-name in which I should use to style a TreeView's rows?
I've tried GtkCellRendererText, but it doesn't work. | false | 13,036,605 | 0 | 0 | 0 | 0 | Silly me, just use GtkTreeView:Hover or GtkTreeView:Selected | 0 | 467 | 0 | 0 | 2012-10-23T18:12:00.000 | python,gtk,pygtk | Styling TreeView's row using CSS | 0 | 1 | 1 | 13,037,240 | 1 |
0 | 0 | I'm trying to get a wxPython app working as an exe. I've heard that PyInstaller is now superior to py2exe. I'd like to include my .ico and two .png files that the script requires to run. What would the spec file for this look like? I can't seem to find a decent example anywhere. I have PyInstaller installed, but I can't find this "makespec" anywhere. | false | 13,059,316 | 0.066568 | 0 | 0 | 1 | Checking for sys.frozen is a really good approach. You can also look into img2py which will let you load the binary data for images into a .py file. Later, instead of having to open files, they can be imported. | 1 | 2,693 | 0 | 2 | 2012-10-24T23:18:00.000 | python,wxpython,exe,pyinstaller | wxPython to exe with PyInstaller? | 0 | 1 | 3 | 13,059,522 | 1 |
0 | 0 | I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background "wraps" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started).
I have no trouble getting the ship and objects to wrap, but the background doesn't show up until the viewport itself passes an edge of the gameworld. Is it possible to make the background surface "wrap" around?
I'm sorry if I'm not being very articulate. It seems like a simple problem and tons of games do it, but I haven't had any luck finding an answer. I have some idea about how to do it by tiling the background, but it would be nice if I could just tell the surface to wrap. | false | 13,059,891 | 0 | 0 | 0 | 0 | I don't think so, I have an idea though. I'm guessing your background wraps horizontally and always to the right, then you could attach part of the beginning to the end of the background.
Example, if you have a 10,000px background and your viewport is 1000px, attach the first 1000px to the end of the background, so you'll have a 11,000px background. Then when the vieport reaches the end of the background, you just move it to the 0px position and continue moving right. | 0 | 1,379 | 0 | 2 | 2012-10-25T00:26:00.000 | python,scroll,pygame,geometry-surface | Wrapping a pygame surface around a viewport | 0 | 3 | 3 | 13,068,085 | 1 |
0 | 0 | I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background "wraps" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started).
I have no trouble getting the ship and objects to wrap, but the background doesn't show up until the viewport itself passes an edge of the gameworld. Is it possible to make the background surface "wrap" around?
I'm sorry if I'm not being very articulate. It seems like a simple problem and tons of games do it, but I haven't had any luck finding an answer. I have some idea about how to do it by tiling the background, but it would be nice if I could just tell the surface to wrap. | false | 13,059,891 | 0 | 0 | 0 | 0 | I was monkeying around with something similar to what you described that may be of use. I decided to try using a single map class which contained all of my Tiles, and I wanted only part of it loaded into memory at once so I broke it up into Sectors (32x32 tiles). I limited it to only having 3x3 Sectors loaded at once. As my map scrolled to an edge, it would unload the Sectors on the other side and load in new ones.
My Map class would have a Rect of all loaded Sectors, and my camera would have a Rect of where it was located. Each tick I would use those two Rects to find what part of the Map I should blit, and if I should load in new Sectors. Once you start to change what Sectors are loaded, you have to shift
Each sector had the following attributes:
1. Its Coordinate, with (0, 0) being the topleft most possible Sector in the world.
2. Its Relative Sector Coordinate, with (0, 0) being the topleft most loaded sector, and (2,2) the bottom right most if 3x3 were loaded.
3. A Rect that held the area of the Sector
4. A bool to indicate of the Sector was fully loaded
Each game tick would check if the bool to see if Sector was fully loaded, and if not, call next on a generator that would blit X tiles onto the Map surface. I
The entire Surface
Each update would unload, load, or update and existing Sector
When an existing Sector was updated, it would shift
It would unload Sectors on update, and then create the new ones required. After being created, each Sector would start a generator that would blit X amount of tiles per update | 0 | 1,379 | 0 | 2 | 2012-10-25T00:26:00.000 | python,scroll,pygame,geometry-surface | Wrapping a pygame surface around a viewport | 0 | 3 | 3 | 13,096,965 | 1 |
0 | 0 | I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background "wraps" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started).
I have no trouble getting the ship and objects to wrap, but the background doesn't show up until the viewport itself passes an edge of the gameworld. Is it possible to make the background surface "wrap" around?
I'm sorry if I'm not being very articulate. It seems like a simple problem and tons of games do it, but I haven't had any luck finding an answer. I have some idea about how to do it by tiling the background, but it would be nice if I could just tell the surface to wrap. | true | 13,059,891 | 1.2 | 0 | 0 | 0 | Thanks everyone for the suggestions. I ended up doing something a little different from the answers provided. Essentially, I made subsurfaces of the main surface and used them as buffers, displaying them as appropriate whenever the viewport included coordinates outside the world. Because the scrolling is omnidirectional, I needed to use 8 buffers, one for each side and all four corners. My solution may not be the most elegant, but it seems to work well, with no noticeable performance drop. | 0 | 1,379 | 0 | 2 | 2012-10-25T00:26:00.000 | python,scroll,pygame,geometry-surface | Wrapping a pygame surface around a viewport | 0 | 3 | 3 | 13,131,429 | 1 |
0 | 0 | My question is not specific to Python/PyQt4 but it's the language and api I'm currently using. I want to know if there is a library to automatically generate GUI forms from public parameters of an object. It would be very useful for automatic settings generation. | false | 13,090,222 | 0 | 0 | 0 | 0 | There is no need for searching fully suited library. Also, i think, it is unnecessary and waste of time. There are lots of frustrating issue, such as localization settings, number format settings, validation issue etc.
I recommend, use Qt designer form layout to create quickly a form.
Then use pyqt4/QValidation and u can use some regular expression(python new regex module better than QRegExp).
At the and of, manage custom objects via jsonpickle or just python pickle. | 0 | 70 | 0 | 1 | 2012-10-26T15:51:00.000 | python,user-interface,pyqt4 | Best practice to generate the settings view of an UI | 0 | 1 | 1 | 14,197,531 | 1 |
0 | 0 | I current am making a GUI using tk, I have implemented a ttk notebook to have two separate tabs, each of these tabs hold data but call the same functions to interact with this data, is that a sane way to do this? Or should I just make more functions to call them separately? They need to know which tab is currently selected.
Thanks. | true | 13,090,227 | 1.2 | 0 | 0 | 1 | okay, this might not be the best way, but for each widget in the tabs, pass through a variable in the functions which will then be used in an if statement to check which tab is currently selected, as you're only using two this could be Boolean? if more is needed more complex step will be needed, but that is a simple way to do this, but not pretty :p
xx | 0 | 1,005 | 0 | 4 | 2012-10-26T15:52:00.000 | python,user-interface,tkinter,ttk | Two tabs using ttk notebook, but separate functions for the two? | 0 | 1 | 2 | 13,090,292 | 1 |
0 | 0 | I'm working on an astronomy project, making one of those gravity simulator programs. I have a Uni class, which represents a universe filled with celestial bodies (instances of the Body class).
This Uni class is capable of updating itself, adding new bodies, and removing bodies by their id. It's completely math-based, and should work alone.
Around it, I'm planning to build the program that uses PyGame to optionally display the simulation in real time and MatPlotLib to analyze the results. However, I am a bit confused over how to keep my computation (Uni) and rendering (Renderer) decoupled!
I envisioned it like this:
The main program:
Imports PyGame, initializes it, and creates a screen.
Instantiates a universe, fills it with bodies, etc (actually done by a FileManager, which reads JSON specs for a uni).
Creates a Renderer
Enters a while run: loop:
uni.update(dt)
#Listen to PyGame events, respond
r.render(screen, uni, ui) #The UI class has a list of UI elements.
However, the renderer needs to keep a persistent list of PyGame surfaces and images that need to be drawn, and there's the problem. Neither the Uni nor Body instances must be aware of PyGame, so they can't keep those themselves.
The renderer, on the other hand, is only there for its render method, which can't just create and destroy PyGame surfaces as needed (I guess that would be performance-heavy).
One possible solution would be to have the renderer have a dictionary of PyGame objects, all identified by body ids. Then, it would iterate over it, remove any gone bodies, and add any new ones each frame.
Is this the right way to go? | true | 13,099,963 | 1.2 | 0 | 0 | 1 | Instead of body ID's why not add the Bodys themselves to the dictionary of pygame objects instead of an ID? After all, a Python variable is just a label, so the renderer wouldn't need to know about what the variable represents. And it might save you having to look-up IDs.
A related option is to add one or multiple viewport objects to your universe. Because no matter what the implementation of the viewing mechanism, you typically don't want to show the whole universe, so a viewport would be a proper attribute of the universe. With that viewport would go a couple of methods (except from creating and sizing). First a method to get all Bodys in the viewport (that could just return a list you'd keep in the viewport object). Second a method to get a tuple containing two lists; one of Bodys that have appeared in the viewport, and second a list of Bodys that gone out of the viewport since the last update. The viewport should also have an update method that is called by the universe's update method. | 1 | 396 | 0 | 1 | 2012-10-27T11:56:00.000 | python,oop,class,decoupling,astronomy | How to properly decouple computation from rendering | 0 | 1 | 1 | 13,100,096 | 1 |
0 | 0 | I have a Widget that is huge (80,000 px long maybe? 800 elements at 100px each) because it lays out many smaller widgets. I've put the huge widget into a QScrollArea. But the scroll area still renders the entire widget. This causes manipulation of the widget to be choppy, and I want things to be smoother.
Instead I want the QScrollAea to be intelligent enough to only render the elements that I know will be displayed. (The elements are ordered and are all the same fixed size, so this computation should be fast)
What's the best approach to go about this? Should QScrollArea already be doing this?
Does QListView already implement this functionality? (But I want my own custom widget in there it has buttons that interact with the user, QListWiget doesn't cut it.) | true | 13,101,486 | 1.2 | 0 | 0 | 1 | Have you considered using a QGraphicsView? This allows scrolling in addition to efficient rendering of only the visible objects (and plenty of other benefits such as hit testing). | 0 | 194 | 0 | 0 | 2012-10-27T15:25:00.000 | python,pyqt | How can I limit the rendering done by QScrollArea? | 0 | 1 | 1 | 13,101,822 | 1 |
0 | 0 | I've been trying for over a week now to make a .exe of a wxPython script. I still have a number of questions, and the process of creating an exe is still quite unclear.
Which utility should be used? I've heard to use py2exe, pyinstaller, gui2exe, some combination of gui2exe and some shady .bat file, etc. Which is best for a wxPython app?
What's the deal with .dlls? What do they do, do I need to "bundle" them, and why wouldn't they be on the user's computer?
Can you bundle things into the .exe, or do they need to be in the directory the .exe is in?
These things have not been made particularly clear, as I've been trying to find out exactly how to make my program into an exe for a while. | true | 13,111,899 | 1.2 | 0 | 0 | 1 | I use pyinstaller as it is very easy to use and the applications run without any problems
Some Windows DDLs are needed for the included Python Compiler and for the maybe win32 api calls
With Pyinstaller you can bundle everything needed (except config files and dbs of course) using the -F flag. | 1 | 2,794 | 0 | 0 | 2012-10-28T18:50:00.000 | python,wxpython,exe | Creating wxPython GUI .exe? | 0 | 1 | 2 | 13,111,965 | 1 |
0 | 0 | I cannot get emacs to evaluate my buffer. I put it into python mode and started the interpreter but C-c C-c does not seem to do anything. I also tried C-c C-l to load the file but after selecting the file nothing happens. Typing directly into the python shell does work.
I tried it out in linux and everything worked fine so I know I am using the correct commands and there is no problem with my code.
I am running GNU Emacs 24.2.1 and Python 3.3 on Windows 7. I am new to emacs and I like it so far, but unless I can get the shell working I will need to switch to a different editor.
Update: I am trying to run an application developed with the Pyglet library which creates its own window to display graphics in.
Update #2: So if I try to evaluate the buffer and then go to the python buffer and stop compilation and then evaluate it again then it works. This is obviously not ideal.
Also maybe related, any errors or exceptions will not show up in the shell unless I go into the shell and hit enter. | false | 13,112,473 | 0 | 0 | 0 | 0 | here output arrives in a buffer *Python*, which is not displayed by default unfortunately. M-x list-buffers should mention it. | 0 | 201 | 0 | 1 | 2012-10-28T20:00:00.000 | python,windows,windows-7,emacs,python-3.3 | Python Pyglet application not working in Windows Emacs | 0 | 1 | 1 | 13,112,953 | 1 |
0 | 0 | I am just getting started with pymunk, and I have a problem that I wasn't able to find a solution to in the documentation.
I have a character body that changes shape during a specific animation. I know how to attach shapes to a physics body, but how do I change them? Specifically, I need to change the box to a smaller one temporarily.
Is that possible? | true | 13,127,381 | 1.2 | 0 | 0 | 1 | There are a couple of unsafe methods to modify a shape. Right now (v3.0) pymunk only supports updates of the Circle shape and the Segment shapes. However, I just committed a method to update the Poly shape as well, available in latest trunk of pymunk.
If you dont want to run latest trunk I suggest you instead just replace the shape instead of modifying it. The end result will be the same anyway.
(The reason why modification of shapes is discouraged is that its very hard to do a good simulation, the resize happen magically in one instant. For example, how should a collision between of a small object that after a resize would lie inside a large object be resolved?) | 0 | 898 | 0 | 1 | 2012-10-29T18:16:00.000 | python,chipmunk,pymunk | Changing the shape of a pymunk/Chipmunk physics body | 0 | 1 | 1 | 13,130,409 | 1 |
0 | 0 | I have looked at similar questions that may answer my question but I am still very unclear on how to go about the following:
I can create programs to run in the Python Shell in Idle and I can also set up windows with widgets in Tkinter, but whatever I create in Tkinter is pointless because I cannot figure out how to take my Python Shell code and "wrap" it in the Tkinter GUI.
I have assumed that it cannot be done, and that entirely new code must be written to assist the language that is specific to Tkinter. I am very confused on how to create a well-rounded program without being left with just a GUI "skeleton" with random buttons, labels, entries, etc. and a Python program that is very unappealing and can only run in the ugly little Shell. | false | 13,128,466 | 0 | 0 | 0 | 0 | What you create with Tkinter is not pointless. It sounds to me like you're trying to compile a stand-alone program in Python, using the Tkinter library to provide the GUI. Once you have a script working, you can use a program to compile into a standalone program. Look into using py2app on a mac, or py2exe on Windows. Google them and see if that's what you're looking for. | 0 | 1,228 | 0 | 0 | 2012-10-29T19:41:00.000 | python,tkinter | Porting a Python Shell Program to a Tkinter GUI | 0 | 1 | 2 | 13,129,010 | 1 |
0 | 0 | Is there a way to use android.py module without installing SL4A?
I mean I have Python running on android successfully from Terminal Emulator.
Can I use that module without installing that layer (or if I can't install it anymore)? | true | 13,137,341 | 1.2 | 1 | 0 | 2 | No, because the SL4A package provides the facade to make device API calls, acting as a middleman. Without it you might be able to import it, but you could not be able to make any API calls. | 0 | 1,256 | 0 | 2 | 2012-10-30T10:46:00.000 | android,python,sl4a,android-scripting | Using Python android.py module without SL4A | 0 | 1 | 1 | 13,215,655 | 1 |
0 | 0 | When trying to install Shapely on my Windows 64bit computer, I cannot get the GEOS library to work.
So far, I have run the OSGeo4W installer from which I installed GDAL (I believe the geos library is included in that package). After that, I checked and I have geos_c.dll on my C:\OSGeo4W\bin directory, but either I have missed some configuration steps or the library does not work.
I need Shapely to work, so I also ran pip install shapely after installing GDAL, and it apparently worked (although it could not find the C library for GEOS).
In my code, I can import Shapely, but when I try to use it, I get an error telling me "geos.dll" is not found.
Any help with this will be very appreciated. Thanks! | false | 13,144,158 | 0.066568 | 0 | 0 | 2 | I tried the method of @jozef but failed even I imported the folder to the path.
A straightforward solution: add geos_c.dll, geos.dll to the library folder of your python environment. Then it works. | 0 | 49,925 | 0 | 23 | 2012-10-30T17:05:00.000 | python,gis,geospatial,shapely | Python, GEOS and Shapely on Windows 64 | 0 | 2 | 6 | 63,239,049 | 1 |
0 | 0 | When trying to install Shapely on my Windows 64bit computer, I cannot get the GEOS library to work.
So far, I have run the OSGeo4W installer from which I installed GDAL (I believe the geos library is included in that package). After that, I checked and I have geos_c.dll on my C:\OSGeo4W\bin directory, but either I have missed some configuration steps or the library does not work.
I need Shapely to work, so I also ran pip install shapely after installing GDAL, and it apparently worked (although it could not find the C library for GEOS).
In my code, I can import Shapely, but when I try to use it, I get an error telling me "geos.dll" is not found.
Any help with this will be very appreciated. Thanks! | false | 13,144,158 | 0.033321 | 0 | 0 | 1 | I used the command below and it did work;
pip install Shapely==1.3.0 | 0 | 49,925 | 0 | 23 | 2012-10-30T17:05:00.000 | python,gis,geospatial,shapely | Python, GEOS and Shapely on Windows 64 | 0 | 2 | 6 | 59,217,091 | 1 |
0 | 0 | A part of a small project I am working on involves 'calibrating' the coordinates of the screen of which to take a screen capture of.
By the 'screen', I refer to the entire desktop, not my GUI window.
The coordinates are calibrated when a QDialog window appears (which I've subclassed).
The user is prompted to click several locations on the screen.
I need the program to record the locations of all mouse clicks occuring anywhere on the screen - ones that don't natively trigger a QDialog mouseEvent, since they are outside this window.
Obviously overwriting the mouseEvent method does not work, since the QDialog doesn't recieve the clicks.
How can I capture global mouse clicks, so that an event is triggered and sent to the QDialog when any part of the screen is clicked?
(I'd prefer a Qt based solution, but am open to other libraries if need be).
Thanks! | true | 13,150,497 | 1.2 | 0 | 0 | 0 | I've assumed this isn't possible and am instead using pyHook,
letting Qt pump the messages. | 0 | 2,065 | 0 | 0 | 2012-10-31T02:39:00.000 | python,user-interface,mouseevent,pyqt4,global | PyQt4 - detect global mouse click | 0 | 1 | 2 | 13,151,661 | 1 |
0 | 0 | My friend has an application written in C that comes with a GUI made using GTK under Linux. Now we want to rewrite the GUI in python (wxpython or PyQT).
I don't have experience with Python and don't know how to make Python communicate with C. I'd like to know if this is possible and if yes, how should I go about implementing it? | false | 13,173,029 | 0 | 0 | 0 | 0 | If you have an option between C or C#(Sharp) then go with C# and use visual studio, you can build the GUI by dragging and dropping components easy. If you want to do something in python look up wxPython. Java has a built in GUI builder known as swing. You'll need some tutorials, but unless this program doesn't need to be portable just go with C# and build it in 10 minutes .
Also, you can write your code in C and export it as a python module which you can load from python. It`s not very complicated to set up some C functions and have a python GUI which calls them. To achieve this you can use SWIG, Pyrex, BOOST. | 0 | 4,672 | 0 | 6 | 2012-11-01T07:52:00.000 | python,c,wxpython,pyqt | Can C programs have Python GUI? | 0 | 1 | 3 | 13,175,997 | 1 |
0 | 0 | I am making a project in pharo that will extend it and make it more visual for also further extending the 3d application Blender. Blender uses mainly python for extensions called "Addons" , to be precise python 3.2. So what I want is to make a bridge between pharo (smalltalk) and blender (python).
For now I have focused on sockets and XMLRPC but I was wondering if there are tools out there and choices to further help on my saga.
I dont have high demands, for now a simple access to class attributes and call of python methods should be enough, but if I can add additional power to my bridge later it will so much better. Ideally the bridge later one could be used for making pharo use libraries from other language like Java , C# etc | false | 13,208,657 | 0.039979 | 0 | 0 | 1 | I remember a ruby->dotNet bridge which was ported to some smalltalk as far as I remember.
(Ruby/.Net Bridge / 2004 Benjamin Schroeder and John R. Pierce). It covered passing of exceptions, callbacks etc. May make a good starting point for your work. Don't know where and how to get it, though. | 0 | 415 | 0 | 3 | 2012-11-03T11:19:00.000 | python,sockets,smalltalk | Making a bridge for communication between python and smalltalk | 0 | 2 | 5 | 13,605,902 | 1 |
0 | 0 | I am making a project in pharo that will extend it and make it more visual for also further extending the 3d application Blender. Blender uses mainly python for extensions called "Addons" , to be precise python 3.2. So what I want is to make a bridge between pharo (smalltalk) and blender (python).
For now I have focused on sockets and XMLRPC but I was wondering if there are tools out there and choices to further help on my saga.
I dont have high demands, for now a simple access to class attributes and call of python methods should be enough, but if I can add additional power to my bridge later it will so much better. Ideally the bridge later one could be used for making pharo use libraries from other language like Java , C# etc | true | 13,208,657 | 1.2 | 0 | 0 | 2 | WebSockets sending JSON messages between Smalltalk and Python could be the bleeding edge yet long-term quite a promising way to go. Smalltalk has quite good WebSockets support, I suppose Python as well. | 0 | 415 | 0 | 3 | 2012-11-03T11:19:00.000 | python,sockets,smalltalk | Making a bridge for communication between python and smalltalk | 0 | 2 | 5 | 13,210,746 | 1 |
0 | 0 | I want to write a tool in Python that will help me create isometric tiles from 3D-models. You see, I'm not a very proficient artist and free 3D-models are plentisome, and creating something like a table or chair is much easer in 3D than in painting.
This script will load a 3D model in orthographic projection and take pictures from four directions so it can be used in a game. I've tried this in Blender, but the results are inconsistent, very difficult to control and take very long time to create simple sprites.
Rolling my own script will probably let me do neat things too, especially batch-genetration, maybe on texture changes, shading, etc. The game itself will probably be made in Python tpp, so maybe I could generate on the fly. (Edit: and automatically creat cut out see-through walls for when they face camera)
Now my question, what Python libraries can do something like this? I've checked both Pyglet and Panda3D, but I haven't even been able to load a model, let alone set it to orthographic projection. | false | 13,208,743 | 0.099668 | 0 | 0 | 1 | I found this code:
www.pygame.org/wiki/OBJFileLoader
It let me load and display an .obj file of a cube from Blender with ease. It runs PyOpenGL so it should let me do everything OpenGL can. Never knew OpenGL was so low-level, didn't realize I'd have to write my own loaders and everything.
Anyway, I'm pretty sure I can modify this to project isometrically, rotate the object and grab shots and combine them into sprites. Thanks you guys! | 0 | 1,835 | 0 | 0 | 2012-11-03T11:32:00.000 | python,3d,isometric | Render 3D model orthographically in Python | 0 | 1 | 2 | 13,214,374 | 1 |
0 | 0 | I am looking for version (custom/beta?) of portable python that is python 3.x and includes pygame. I know pygame hasn't been fully converted to 3.x yet, but for what I need it for it works perfectly. | true | 13,219,237 | 1.2 | 0 | 0 | 1 | Install Pygame, then take your entire Python folder and put it where you want it to go.
If you mean you want to be able to use python (filename).py on the terminal, then you will have to change the PATH variable in the terminal, or add the shebang line #!usr\bin\python onto your programs. | 0 | 2,264 | 0 | 0 | 2012-11-04T14:06:00.000 | python,python-3.x,pygame,portable-executable | portable python 3.x and pygame | 0 | 1 | 3 | 13,242,922 | 1 |
0 | 0 | I have created a program that takes pictures with your webcam.
I used Pygame and VideoCapture. It all works fine as .pyw file, but after it is compiled with py2exe it is just doesn't work.
From my research, the error is coming from trying to compile the VideoCapture module.
PLEEASSEE HELP ME!!!
(The Same error occurs for Pyinstaller) | false | 13,219,380 | 0.099668 | 0 | 0 | 1 | have you tried compiling with cx_freeze? | 1 | 165 | 0 | 4 | 2012-11-04T14:25:00.000 | python,pygame,py2exe | py2exe not compiling VideoCapture correctly | 0 | 1 | 2 | 13,646,270 | 1 |
0 | 0 | Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it. Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things. I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags. | false | 13,222,607 | 0 | 0 | 0 | 0 | You can do this, the library is called tkinter. | 1 | 336 | 0 | 0 | 2012-11-04T20:33:00.000 | python,user-interface,window | Can you run python as a windowed program? | 0 | 2 | 3 | 13,222,646 | 1 |
0 | 0 | Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it. Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things. I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags. | false | 13,222,607 | 0 | 0 | 0 | 0 | There are many GUI libraries to choose from, but I like Tkinter because it's easy and there's nothing to install (it comes with Python).
But some people prefer wxPython or others, such as PyQT. You'll have to decide which you like, or just go with Tkinter if you don't want to go through the trouble of installing libraries just to try them out. | 1 | 336 | 0 | 0 | 2012-11-04T20:33:00.000 | python,user-interface,window | Can you run python as a windowed program? | 0 | 2 | 3 | 13,222,783 | 1 |
0 | 0 | If this is possible, can you show some code example? Thanks in advance. | true | 13,248,848 | 1.2 | 0 | 0 | 1 | ObjectListView is just a nice wrapper around the ListCtrl. To my knowledge, the ListCtrl does not support the embedding of other widgets. You could create a popup dialog when double-clicking a cell and do it that way. Otherwise, you would have to use the UltimateListCtrl. That widget DOES allow widget embedding because it's a custom widget rather than a native one. | 0 | 203 | 0 | 0 | 2012-11-06T10:15:00.000 | python-2.7,wxpython,wxwidgets | Can we embedd a ComboBox or a TextCtrl on the ObjectListView of wxPython? | 0 | 1 | 1 | 13,254,838 | 1 |
0 | 0 | Where would be a good place start learning to program a clipboard manager in python. i want to be able to copy selected text with a keyboard macro and set it to a slot identified ny the key combo "ctrl+alt+c+1", "ctrl+alt+c+2" storing more than one thing, also so would be got to be able to contaminate on to what is in a slot, if one would want. Any way that is the project i want to write, i write in python 3.2, python 2.7, and java 7. what libraries should i start learning i guess is what i am asking. | true | 13,258,448 | 1.2 | 0 | 0 | 0 | Clipboards are framework specific. So a good place would be to select a GUI framework, and look at it's documentation for how to deal with cut and paste. | 0 | 964 | 0 | 0 | 2012-11-06T19:59:00.000 | python-3.x,clipboardmanager | Python clipboard manager? | 0 | 1 | 1 | 13,261,057 | 1 |
0 | 0 | Where does boost python register from python converters for builtin types such as from PyLong_Type to double?
I want to define a converter that can take a numpy.float128 from python and returns a long double for functions in C++. I already did it the other way round, the to_python converter. For that I tweaked builtin_converters.hpp but I didn't find how boost python does the from python conversion. | true | 13,267,912 | 1.2 | 1 | 0 | 1 | The from python conversion is in fact done in builtin_converters.cpp and not in the header part of the library. I Copied this file and deleted everything except the converter for long double, which I was then able to modify. | 0 | 300 | 0 | 2 | 2012-11-07T10:36:00.000 | c++,python,boost-python | From python converter for builtin types | 0 | 1 | 2 | 13,363,934 | 1 |
0 | 0 | I'm working on a project in Python using tkinter that will allow for geolocation of IP addresses. I have the raw conversions down, and I can take an IP address and know city, state, country, longitude, latitude, etc. I'm wondering if there's any way to embed Google Maps or something similar into my program to offer a visual representation. | false | 13,295,331 | 0.099668 | 0 | 0 | 1 | Most GUI Frameworks have a way to embed a web browser frame, with a way to execute javascript from the python code. If this is available to you, you could use the Google Maps JavaScript API v3 to display a map.
If you let us know which GUI framework you're using, we might be able to help more. | 1 | 7,845 | 0 | 5 | 2012-11-08T18:25:00.000 | python,google-maps,tkinter | How can I embed google maps into my Python program? | 0 | 1 | 2 | 13,311,950 | 1 |
0 | 0 | I have created a QTreeWidget and set animation to true (setAnimated(true)).
When I'm clicking on a mark (triangle) at the left of item it expands smoothly, but when I'm double clicking on the item it expands too fast (almost like there is no "animated" flag set).
I want smooth animation on double click too. How can I solve this problem?
QTreeView calls QTreeViewPrivate::expandOrCollapseItemAtPos on mark click and QTreeViewPrivate::expand on double click, so I have no access to these methods.
I'm using PySide for creating Qt application (but I've tried C++ and the problem is the same). | false | 13,304,136 | 0.099668 | 0 | 0 | 1 | You need to override the click behaviour. Check the event if it's a double click or not and then you can redirect the event to the appropriate call. You should check the state if it's already clicked or not to prevent a second animation which might happen. | 0 | 1,404 | 0 | 4 | 2012-11-09T07:49:00.000 | python,qt4,python-2.7,pyside,qtreewidget | QTreeWidget expand animation on double click | 0 | 1 | 2 | 15,232,509 | 1 |
1 | 0 | I am doing an application with GUI using WPF/XAML with Ironpython and SharpDevelop, until now it works fine, when I'm in the development environment I can see the errors in console and know what is wrong.
But when I build and deploy the app for us on other system or I ran it outside of the development environment and there is no longer the console when there is some error or crashes, it fails silently, and I cannot know what went wrong.
How can I alert or log to see what fails? | true | 13,347,378 | 1.2 | 0 | 0 | 1 | You could put in some code to catch the error and log it to a file.
Something possibly simpler is to compile your application as a Console Application. This can be done via Project Options - Application - Output type. Then you will get a console window when you run your WPF application and any exception that happens at startup will be logged to this window. | 0 | 240 | 0 | 0 | 2012-11-12T16:22:00.000 | wpf,xaml,ironpython,sharpdevelop | Ironpython: How to see when a WPF application fails? | 0 | 1 | 1 | 13,352,605 | 1 |
0 | 0 | I am new to Mac, have always used windows and I am confused on how to install wxPython. I downloaded the .dmg file from the website, and it contained three files:
a pkg file, a readme, and an uninstall.py
I opened the pkg file, went through the steps, and Im not sure where it installed after it said "Installation Complete"
Also, I did the import wx in idle, which caused a stacktrace error.
Thanks. | true | 13,354,317 | 1.2 | 0 | 0 | 2 | At least for development, I would suggest to install (python and) wx using homebrew. It will install version 2.9 and you're ensured that Apple-provided system libraries remain untouched. | 0 | 363 | 0 | 0 | 2012-11-13T01:22:00.000 | macos,installation,wxpython | Install wxpython on mac | 0 | 1 | 2 | 13,357,833 | 1 |
0 | 0 | This might be a bit foolish but I'm trying to use ctypes to call a function that receives a complex vector as a paramter. But in ctypes there isn't a class c_complex.
Does anybody know how to solve this?
edit: I'm refering to python's ctypes, in case there are others.... | false | 13,373,291 | -0.039979 | 0 | 0 | -1 | If c_complex is a C struct and you have the definition of in documentation or a header file you could utilize ctypes to compose a compatible type. It is also possible, although less likely, that c_complex is a typdef for a type that ctypes already supports.
More information would be needed to provide a better answer... | 0 | 2,911 | 0 | 4 | 2012-11-14T04:59:00.000 | python,ctypes,complex-numbers | Complex number in ctypes | 0 | 1 | 5 | 13,373,641 | 1 |
0 | 0 | I'm writing a multi-threaded application that utilizes QThreads. I know that, in order to start a thread, I need to override the run() method and call that method using the thread.start() somewhere (in my case in my GUI thread).
I was wondering, however, is it required to call the .wait() method anywhere and also am I supposed to call the .quit() once the thread finishes, or is this done automatically?
I am using PySide.
Thanks | true | 13,376,448 | 1.2 | 0 | 0 | 1 | Both answers depend on what your code is doing and what you expect from the thread.
If your logic which uses the thread needs to wait synchronously for the moment QThread finishes, then yes, you need to call wait(). However such requirement is a sign of sloppy threading model, except very specific situations like application startup and shutdown. Usage of QThread::wait() suggests creeping sequential operation, which means that you are effectively not using threads concurrently.
quit() exits QThread-internal event loop, which is not mandatory to use. A long-running thread (as opposed to one-task worker) must have an event loop of some sort - this is a generic statement, not specific to QThread. You either do it yourself (in form of some while(keepRunning) { } cycle) or use Qt-provided event loop, which you fire off by calling exec() in your run() method. The former implementation is finishable by you, because you did provide the keepRunning condition. The Qt-provided implementation is hidden from you and here goes the quit() call - which internally does nothing more than setting some sort of similar flag inside Qt. | 1 | 438 | 0 | 1 | 2012-11-14T09:52:00.000 | python,multithreading,qt,thread-safety,qthread | Do I need to manually call .quit() method when QThread() stops running (Python)? | 0 | 1 | 1 | 13,381,623 | 1 |
0 | 0 | I have got a python function that takes a few parameters and executes a few tasks (let's call it theFunc). While theFunc runs, internal variable resultingMessage is getting more and more lines, and I show it on GUI at the end of the execution. Ideally, I would like resultingMessage to be shown and updated on GUI as the execution of theFunc happens, not after it has finished, and to do it without polluting theFunc with GUI stuff (it is complicated enough already). What would be the best way to do it?
Two possible ways I could think of (both are quite far-fetch):
Have two threads: one executed theFunc and writes resultingMessage in a variable/file, the other checks this variable/file and updates GUI;
Instead of appending lines to resultingMessage, attach some "stream" to GUI element; adding lines to the "stream" would update GUI.
I guess there should be a conventional way to do it.
Environment: CPython 2.7, Win XP, WXPython | false | 13,417,553 | 0.099668 | 0 | 0 | 1 | You would want to use threads. wxPython provides several thread-safe methods such as wx.CallAfter, wx.CallLater and wx.PostEvent. You can combine those with pubsub to send messages too! In your case, I think passing a wx method to wx.CallAfter with whatever text you wish to display would work just fine. | 1 | 487 | 0 | 1 | 2012-11-16T13:26:00.000 | python,user-interface,wxpython,auto-update | Updating GUI while execution a python function while keeping this function GUI-independent | 0 | 1 | 2 | 13,418,479 | 1 |
0 | 0 | In Pygame, how can I get graphical input(e.g. clicking exit button) and also get input from the a terminal window simultaneously?
To give you context, my game has a GUI but gets its game commands from a "input()" command. How can I look for input from the command line while also handling graphics?
I'm not sure if this is possible, but if not, what other options do I have for getting text input from the user?
Thanks in advance. | true | 13,450,878 | 1.2 | 0 | 0 | 1 | You can't do that, unless you use the input command in a different thread, but then you have to deal with syncronization (which might be what you want or don't want to do).
The way I'd implement this is to create a kind of in-game console. When a special key (e.g. '\') is pressed you make the console appear, and when your application is in that state you interpreter key pressing not as in-game commands but... well, as text. You can print them in the console (using fonts). When a key (e.g "return") is pressed you can make the console disappear and the keys take back their primary functionality.
I did this for my pet-project and it works as a charm. Plus, since you are developing in python you can accept python instructions and use exec to execute them and edit your game "on fhe fly" | 0 | 906 | 0 | 2 | 2012-11-19T09:28:00.000 | python,input,pygame | Pygame: Graphical Input + Text Input | 0 | 1 | 1 | 13,451,666 | 1 |
0 | 0 | I created a main app with a mdiArea for loading map graphics with Qt Designer *.ui and coded with pyQt4 using uic.loadUi() in python.
I also created a separate *.ui file and tested the dockWidget successfully in a separate python script file.
I wish to combine these 2 UI so that the main_app window will have the mdiArea widget on the left, while the dockWidget as the info_panel on the right.
I tried to load the *.ui file in the main app python, but ended up the dockWidget as a separate window when show().
Any advice to resolve this?
I hope I need not have to use Qt Designer to combine the mdiArea main_app UI with the dockWidget info_panel and load them as a single UI. ;P
Thanks in advance. | false | 13,466,072 | 0 | 0 | 0 | 0 | I've worked on some software where every different pane is done as a separate. Ui file, so that they can be changed independently without requiring merges. It worked fine. Can you turn the map and dock parts into widgets, and then make a new "main window" ui, and then give that a layout and add the other two as child widgets to it? | 0 | 719 | 0 | 1 | 2012-11-20T03:15:00.000 | python,pyqt4 | Combining 2 UI as one main app window in python | 0 | 1 | 1 | 13,470,421 | 1 |
0 | 0 | I use Python 3 and unofficial PIL module. My code works fine. But after using cx_freeze I get exception "_imaging c module is not installed".
What can I do with this problem? All solutions that I found were about Python 2.X and Linux OS. I need the solution for Windows and Python 3. | false | 13,470,611 | 0 | 0 | 0 | 0 | The only reason i know of that that can happen is if the _imagingtk.pyd is not for your python version.
Oh, could you post the link to the unofficial version? I've been searching for it for awhile. | 1 | 348 | 0 | 1 | 2012-11-20T09:55:00.000 | windows,python-3.x,cx-freeze | After using cx_freeze I get exception _imaging c module is not installed | 0 | 1 | 3 | 13,814,960 | 1 |
0 | 0 | I have a title ("cadeau check 50 €") in a form value that I want to write to a background image with arial.ttf. My text is correct but for the euro sign. I have 2 [] in place. I don't know where the problem is coming from. Is this an encoding problem in PIL, or have I a problem with the font? | false | 13,476,383 | 0 | 0 | 0 | 0 | Maybe use Unicode strings?? Like u'cadeau check 50 €' ... Now, does also your font have the corresponding glyphs? | 1 | 785 | 0 | 2 | 2012-11-20T15:23:00.000 | python,python-imaging-library,python-unicode | PIL: how to draw € on an image with draw.text? | 0 | 1 | 2 | 13,476,705 | 1 |
0 | 0 | I got a tkMEssagebox.showerror showing up in a python tkinter application,
when somebody failed to login with the application.
Is it possible to have a url link in the tkMessageBox.showerror?
ie.
tkMessageBox.showerror("Error","An error occured please visit
www.blahblubbbb.com")
and I want the www.blahblubbbb.com to be clickable?! | true | 13,508,043 | 1.2 | 0 | 0 | 3 | Short answer: "No!" message is a simple string, no interpretation like in some widgets of other frameworks is done.
Longer answer: You could e.g. subclass+monkeypatch, to provide such feature. | 0 | 2,245 | 0 | 6 | 2012-11-22T07:51:00.000 | python,python-2.7,tkinter,tkmessagebox | tkinter tkMessageBox html link | 0 | 1 | 1 | 13,508,222 | 1 |
0 | 0 | Is there any way to change the width of the block which is moving on gtk.ProgressBar.pulse()? | false | 13,525,032 | 0 | 0 | 0 | 0 | Not on PyGTK. If you are using GTK 3 then there is a CSS class, GtkProgressBar:pulse, but I can't find any documentation on how to change the width. It might be possible if you do some digging. | 0 | 216 | 0 | 1 | 2012-11-23T07:57:00.000 | python,pygtk | ProgressBar: set the width of the pulse block | 0 | 1 | 1 | 13,541,432 | 1 |
0 | 0 | I am developing Ubuntu app using the Unity tools (PyGTK + Python). I can change label font-size with no problem, but I cannot find same thing for button. How can I change button font-size?
The purpose of this is, i am developing an on-screen keypad, so the numerical text needs to be bigger so that it is easier to be seen. | true | 13,538,069 | 1.2 | 0 | 0 | 1 | The button contains a label, which you can access with get_child() and related functions. You can change the label's font size using the normal method. | 0 | 2,417 | 0 | 1 | 2012-11-24T03:50:00.000 | python,pygtk | Glade + PyGTK Change Button Font Size | 0 | 1 | 1 | 13,541,300 | 1 |
0 | 0 | I read few Boost.Python tutorials and I know how to call C++ function from Python. But what I want to do is create C++ application which will be running in the background all the time and Python script that will be able to call C++ function from that instance of C++ application. The C++ application will be a game server and it has to run all the time. I know I could use sockets/shared memory etc. for this kind of communication but is it possible to make it with Boost.Python? | false | 13,553,174 | 0.379949 | 1 | 0 | 2 | Boost python is useful for exposing C++ objects to python.
Since you're talking about interacting with an already running application from python, and the lifetime of the script is shorter than the lifetime of the game server, I don't think boost python is what you're looking for, but rather some form of interprocess communication.
Whilst you could create your IPC mechanism in C++, and then expose it to python using boost python, I doubt this is what you want to do. | 0 | 426 | 0 | 1 | 2012-11-25T16:51:00.000 | c++,python,boost,boost-python | Boost.Python - communication with running C++ program | 0 | 1 | 1 | 13,558,179 | 1 |
0 | 0 | I want to create an application that is capable of loading plugins. The twist is that I want to be able to create plugins in both C/C++ and Python.
So I've started thinking about this and have a few questions that I'm hoping people can help me with.
My first question is whether I need to use C/C++ for the "core" of the application (the part that actually does the loading of the plugins)? This is my feeling at least, I would think that implementing the core in Python would result in a nasty performance hit, but it would probably simplify loading the plugins dynamically.
Second question is how would I go about defining the plugin interface for C/C++ on one hand and Python on the other? The plugin interface would be rather simple, just a single method that accepts a list of image as a parameter and returns a list of images as a return value. I will probably use the OpenCV image type within the plugins which exists for both C/C++ and Python.
Finally, I would like the application to dynamically discover plugins. So if you place either a .py file or a shared library file (.so/.dll) in this directory, the application would be able to produce a list of available plugins at runtime.
I found something in the Boost library called Boost.Extension (http://boost-extension.redshoelace.com/docs/boost/extension/index.html) but unfortunately it doesn't seem to be a part of the official Boost library and it also seems to be a bit stale now. On top of that, I don't know how well it would work with Python, that is, how easy it would be to create Python plugins that fit into this mechanism.
As a side note, I imagine the application split into two "parts". One part is a stripped down core (loading and invoking plugin instances from a "recipe"). The other part is the core plus a GUI that I plan on writing in Python (using PySide). This GUI will enable the user to define the aforementioned "recipes". This GUI part would require the core to be able to provide a list of available plugins.
Sorry for the long winded "question". I guess I'm hoping for more of a discussion and of course if anybody knows of something similar that would help me I would very much appreciate a pointer. I would also appreciate any concise and to the point reading material about something similar (such as integrating C/C++ and Python etc). | false | 13,555,278 | 0.197375 | 1 | 0 | 1 | Write your application in Python, then you can have a folder for your plugins.
Your application searches for them by checking the directory/traversing the plugin tree.
Then import them via "import" or use ctypes for a .so/.dll, or even easier: you can use boost::python for creating a .so/.dll that you can 'import' like a normal python module.
Don't use C++ and try to do scripting in Python - that really sucks, you will regret it. ;) | 0 | 648 | 0 | 0 | 2012-11-25T20:40:00.000 | c++,python,c,plugins,shared-libraries | Application that can load both C/C++ and Python plugins | 0 | 1 | 1 | 13,555,348 | 1 |
0 | 1 | PyOpenGL docs say:
Because of the way OpenGL and ctypes handle, for instance, pointers, to array data, it is often necessary to ensure that a Python data-structure is retained (i.e. not garbage collected). This is done by storing the data in an array of data-values that are indexed by a context-specific key. The functions to provide this functionality are provided by the OpenGL.contextdata module.
When exactly is it the case?
One situation I've got in my mind is client-side vertex arrays back from OpenGL 1, but they have been replaced by buffer objects for years. A client side array isn't required any more after a buffer object is filled (= right after glBufferData returns, I pressume).
Are there any scenarios I'm missing? | true | 13,584,900 | 1.2 | 0 | 0 | 1 | Are there any scenarios I'm missing?
Buffer mappings obtained through glMapBuffer | 0 | 176 | 0 | 1 | 2012-11-27T13:04:00.000 | python,opengl,ctypes,pyopengl | What is PyOpenGL's "context specific data"? | 0 | 1 | 1 | 13,585,375 | 1 |
0 | 0 | I have a simple tkinter window. It consists of a small window, a timer, and a button to set timer. I don't want to go in details with the code.
I want to change the background of all the widgets in my window(buttons, label, Etc.).
My first thought is to use a global variable which I will set to "red" for example, and associate all the widgets background option with the global variable. Then, on button press I will change the global variable to "green" (so that the background of all widgets change) but nothing happens.
My understanding was the .mainloop() sort of updated the window. How can I have the widgets to change background color when my variable change without restarting my application? | false | 13,588,908 | 0.197375 | 0 | 0 | 3 | The background colors will not automatically change. Tkinter has the ability to do such a thing with fonts but not with colors.
You will have to write some code to iterate over all of the widgets and change their background colors. | 0 | 21,940 | 0 | 9 | 2012-11-27T16:41:00.000 | python,tkinter | Dynamically change widget background color in Tkinter | 0 | 1 | 3 | 13,590,474 | 1 |
0 | 0 | Can I set application icon using clean Python 3?
I have .ico file in same directory and want to add into application.
(Without tkinter) | true | 13,632,479 | 1.2 | 0 | 0 | 1 | Short answer: No, you can not. The application icon is set in completely different ways in different environments. Usually it is a setting on the shortcut.
Longer answer: It also depends on what you mean with "Application Icon".
If you mean the icon for the menu entry in the Applcartions/Start/Whatever menu, then you can probably set it with Python, when you are creating the shortcut in whatever menu system you are using, but it will be specific for your system and not portable.
There may be some library out there to help you create installers for different systems that can help you, but it's definitely no longer "clean Python 3" in any meaningful sense. :-) | 1 | 156 | 0 | 0 | 2012-11-29T18:39:00.000 | python-3.x,icons | Application Icon in Python 3 | 0 | 1 | 1 | 13,632,646 | 1 |
0 | 0 | This is for a computer science assignment using Python, does anybody know where I would begin to create an algorithm to create a square or box that rolls across the screen? And I do indeed mean roll, not slide. It does not necessarily have to be using python, I just need a general idea as to how the coordinates would work and a general algorithm. | true | 13,639,219 | 1.2 | 0 | 0 | 2 | If a unit square starts out with one side resting on the x-axis, and the lower right corner at (xs, 0), then after a quarter turn clockwise it will again have one side resting on the x-axis, and the lower right corner now at (xs+1, 0). Before it turns, label the lower left corner a; the upper left, b; and the upper right, c. Corners a and c move along arcs of a unit circle as the square turns. Corner b moves with radius d = sqrt(2).
This leads to the following method: Step angle t from 0 to pi/2 (ie 90°), letting
• xa = xs - cos t
• ya = sin t
• xb = xs - d*cos(t+pi/4)
• yb = d*sin(t+pi/4)
• xc = xs + sin t
• yc = cos t
At each time step, erase the old square by drawing background-colored lines, compute new (xa,ya,xb,yb,xc,yc) from equations, draw new square with lines from (xs,0) to (xa,yb) to (xc,yc) to (xd,yd) to (xs,0), and then delay appropriate amount. Each time t gets up to pi/2, set t back to 0 and add 1 to xs. Note, instead of erasing the whole square and then drawing the new, one might try erasing one old line and drawing one new line in turn for the four sides. | 1 | 244 | 0 | 0 | 2012-11-30T04:52:00.000 | python,algorithm,graphics | Create a square that rolls across the screen | 0 | 2 | 3 | 13,639,414 | 1 |
0 | 0 | This is for a computer science assignment using Python, does anybody know where I would begin to create an algorithm to create a square or box that rolls across the screen? And I do indeed mean roll, not slide. It does not necessarily have to be using python, I just need a general idea as to how the coordinates would work and a general algorithm. | false | 13,639,219 | 0 | 0 | 0 | 0 | You could alternatively completely break the spirit of the assignment by using pybox2d, pymunk or another physics engine to do all the calculations for you. Then you could have lots of boxes rolling around and bouncing off each other :D | 1 | 244 | 0 | 0 | 2012-11-30T04:52:00.000 | python,algorithm,graphics | Create a square that rolls across the screen | 0 | 2 | 3 | 13,639,761 | 1 |
0 | 0 | I'm writing a document based application in wxPython, by which I mean that the user can have open multiple documents at once in multiple windows or tabs. There are multiple kinds of documents, and the documents can all be in different "states", meaning that there should be different menu options available in the main menu.
I know how to disable and enable menu items using the wx.EVT_UPDATE_UI event, but I can't figure out how to pull off a main menu that changes structure and content drastically based on which document that currently has focus. One of my main issues is that the main menu is created in the top level window, and it has to invoke methods in grand children and great grand children that haven't even been created yet.
Contrived example; when a document of type "JPEG" is open, the main menu should look like:
File Edit Compression Help
And when the user switches focus (CTRL+Tab) to a document of type "PDF", the main menu should change to:
File Edit PDF Publish Help
And the "Edit" menu should contain some different options from when the "JPEG" document was in focus.
Current I'm just creating the menu in a function called create_main_menu in the top level window, and the document panels have no control over it. What would be necessary to pull off the kind of main menu scheme I describe above, specifically in wxPython? | false | 13,655,152 | 0 | 0 | 0 | 0 | Probably the only way to do it with the standard wx.Menu is to destroy and recreate the entire menubar. You might be able to Hide it though. Either way, I think it would be easiest to just put together a set of methods that creates each menubar on demand. Then you can destroy one and create the other.
You might also take a look at FlatMenu since it is pure Python and easier to hack. | 0 | 2,119 | 0 | 1 | 2012-12-01T00:34:00.000 | python,wxpython | How do I manage a dynamic, changing main menu in wxPython? | 0 | 1 | 2 | 13,687,868 | 1 |
0 | 0 | Basically I want to do this:
when the user presses a button, the application should open a dialog with a spinner inside of it, while some tasks are executed in background. When this tasks are finished, this dialog should be destroyed, and a new dialog should be opened.
I'm working with python and gtk
How can I do it?
thanks! | true | 13,672,316 | 1.2 | 0 | 0 | 2 | Basically there are two ways. The difference is who is the "main" program. If you want gtk to be in charge, you just create your dialog, and set up an callback for use when idle (gobject.idle_add). This job should make sure that it doesn't take long every step, so gtk can update the gui (you probably want gobject.timeout_add for your spinner).
The other way is that your "background" job is in control. It can just do what it wants, it should just call gtk every now and then (while gtk.events_pending (): gtk.main_iteration (False)) to make sure gtk can update the gui. | 0 | 340 | 0 | 0 | 2012-12-02T18:24:00.000 | python,gtk | gtk loading dialog while performing task | 0 | 1 | 1 | 13,672,419 | 1 |
0 | 0 | I'm trying to find a way to rapidly develop (or rather eventually reach a point where I can rapidly develop) very nice looking cross platform GUI desktop apps that have a very small footprint on disk and in memory, launch very fast (much faster, for example, than even a bare bones wxPython window) (for a good example, look at how fast TextEdit launches under OSX. That's the kind of launch speed I want for my GUI apps), deploy easily, and interact very well with the operating system (Gimp and Gedit and various other open source, cross platform apps exhibit various behaviors that I really hate, depending on the platform, but especially on OSX) without spending any money. (Hey, stop laughing! =P)
I'm dissatisfied with wxWidgets, Qt, SDL, and everything else I've tried so far, so I'm down to writing native GUI code (especially the part that interacts with the OS's windowing system) on each platform, using native tools (XCode/ObjC/Cocoa/OpenGL, MSVC/Win32/DirectX, gcc/GTK/OpenGL), and then trying to come up with some way of writing as much as possible of the rest of the program in Python.
I've thought about maybe writing a set of shared libraries / dll's to deal with matters GUI, and then wrapping them with a set of Python C extensions, but there are some technical challenges involved in doing that when it comes to packaging (menus, the app icon, certain OS-specific application manifests, etc), and I'm not sure that launch speed and performance in general will be acceptable, depending on the particular program I'm writing.
So I've thought about maybe creating a sort of a "shell" program on each platform, and embedding python, kind of in a similar way to the way Sublime Text 2 does.
I don't like the startup slowness that occurs when launching any python program for the first time. I was hoping this was a result of compiling to byte code, and that I could just include precompiled versions of python modules with my apps, but from experimenting, it seems this is not the case.. it seems that the first time anything python runs (since the last system reboot), a shared library / dll is loaded or something. So that's one reason I think of maybe embedding Python - I wonder if there are some options available when imbedding/calling python that could help reduce that launch delay. Or if worst comes to worst, in the imbedded case I can launch without Python, then launch Python if/when I need to, asynchronously (not in the main thread), after the app has already launched.
Is there a way to reduce the first-time launch delay for deployed python programs (ie., programs who's packages include a version of the intepreter.. maybe the interpreter can be compiled with switches I haven't tried)?
Is there any way to reduce the interpreter load/initialize delay when embedding python?
Is it completely unrealistic to expect any python gui program to launch as fast or have as small a footprint as TextEdit? | false | 13,681,305 | 0 | 0 | 0 | 0 | You can take the openoffice way on windows platform and write a launcher that simply tries to access the file needed by your software, so that they will end up in the memory cache, speeding up the startup time (but creating useless things in the cache, in case the user doesn't want to open your program). | 0 | 722 | 0 | 2 | 2012-12-03T10:27:00.000 | python,c,user-interface,cross-platform | Should I embed or extend python to create high quality, high speed GUI programs? | 0 | 1 | 2 | 13,681,502 | 1 |
0 | 0 | I am creating guis with wxPython then compiling them using pyInstaller and finally using inno to set them up.
seeing as i am new to all of this i would like to know, do i need to use UPX to compress just the final compiled exe? or all of the stuff the exe needs to run aswell?
thanks, sorry for being a noob. | true | 13,688,815 | 1.2 | 0 | 0 | 0 | I don't think you can compress the files before the exe or you'll run into issues of Python not being able to read the zip files. You might be able to use eggs here, but I don't believe eggs are compressed. I would just try compressing the exe with UPX and see how it goes.
I personally don't worry about it. The exe's usually are 20-40 MB and hard disk space is cheap and plentiful. | 1 | 325 | 0 | 0 | 2012-12-03T17:45:00.000 | python,wxpython,inno-setup,pyinstaller,upx | Compressing a compiled wxPython program with UPX | 0 | 1 | 1 | 13,690,799 | 1 |
0 | 0 | I cannot get my code to run on my win8 laptop. I am working with a combination of:
Stackless Python 2.7.2
Qt 4.8.4
PySide 1.1.2
Eclipse/Pydev and WingIDE
This works well on my Win7 PC, but now i have bought a demo laptop with windows 8. As far as I know all is installed the same way as on my PC.
When i run my program (same code) now, i get a warning:
"Qt: Untested Windows version 6.2 detected!"
Ok, so that could be the source of my problem, but also i get errors:
some times the program just quits after the warning above (i think only eclipse)
sometimes i get an APPCRASH (i think only eclipse)
sometimes i get the exception: TypeError: Error when calling the metaclass bases: mro() returned base with unsuitable layout ('')
sometimes i get the exception: TypeError: Error when calling the metaclass bases: multiple bases have instance lay-out conflict
Especially the last two don't seem like a windows problem, but i don't see any other difference with my PC win7 install. Does anyone have any idea what is going on or how to fix this? Did i miss a step in the installation or is it some incompatibility maybe?
Cheers, Lars
Does anyone have some input on this? | false | 13,702,106 | 0.099668 | 0 | 0 | 1 | I had the same problem with Pyside 1.1.2 and Qt 4.8.4. The solution for me was to set the compatibility mode of the Python executable to Windows 7 via right click on the executable -> Properties -> Compatiblity -> Run this program in compatibility mode for: Windows 7
Hope that helps. | 1 | 2,146 | 0 | 2 | 2012-12-04T11:42:00.000 | python,qt,windows-8,pyside,stackless | windows 8 incompatibility? | 0 | 2 | 2 | 16,126,325 | 1 |
0 | 0 | I cannot get my code to run on my win8 laptop. I am working with a combination of:
Stackless Python 2.7.2
Qt 4.8.4
PySide 1.1.2
Eclipse/Pydev and WingIDE
This works well on my Win7 PC, but now i have bought a demo laptop with windows 8. As far as I know all is installed the same way as on my PC.
When i run my program (same code) now, i get a warning:
"Qt: Untested Windows version 6.2 detected!"
Ok, so that could be the source of my problem, but also i get errors:
some times the program just quits after the warning above (i think only eclipse)
sometimes i get an APPCRASH (i think only eclipse)
sometimes i get the exception: TypeError: Error when calling the metaclass bases: mro() returned base with unsuitable layout ('')
sometimes i get the exception: TypeError: Error when calling the metaclass bases: multiple bases have instance lay-out conflict
Especially the last two don't seem like a windows problem, but i don't see any other difference with my PC win7 install. Does anyone have any idea what is going on or how to fix this? Did i miss a step in the installation or is it some incompatibility maybe?
Cheers, Lars
Does anyone have some input on this? | false | 13,702,106 | 0 | 0 | 0 | 0 | try using Hyper-V however Hyper-V is not installed by default in Windows 8. You need to go "Turn Windows features on or off." | 1 | 2,146 | 0 | 2 | 2012-12-04T11:42:00.000 | python,qt,windows-8,pyside,stackless | windows 8 incompatibility? | 0 | 2 | 2 | 13,881,726 | 1 |
0 | 0 | Am working on a pyqt app, done the ui via qt-designer 4.8.1, and generated the corresponding py file using pykdeuic4 (available on OpenSuse 12.2), but can't find an equivalent for pyrcc4 to hadle the *.qrc files.
what's the equivalent tool/command?
Edit:
Most of the documentation on using QtDesigner with PyQt, indicates using pyuic4 / pyuic (which on my platform is pykdeuic4), but as for the other tool pyrcc4 / pyrcc, I can't find an equivalent.
Am wondering, where can I even get the original tool from (pyrcc4)? | false | 13,727,279 | 0 | 0 | 0 | 0 | Well, turns out all I needed was to install the extra package python-qt4-utils ontop of the existing python-qt4. Now, I have the sought after utilities in place. | 0 | 452 | 0 | 1 | 2012-12-05T15:58:00.000 | python,pyqt4,opensuse,kde-plasma,pyrcc | Equivalent of pyrcc4 on KDE | 0 | 1 | 2 | 13,730,501 | 1 |
0 | 0 | Is there a single command to clean the screen of the Python Interpreter every time one runs a code in PyScripter?
thanks, | true | 13,738,301 | 1.2 | 0 | 0 | 6 | Goto pyscripter menus and check the box for clear output before run.
Tools>Options > IDE options > Python interpreter > Clear output before run.
Very useful in interactive sessions. | 1 | 2,810 | 0 | 3 | 2012-12-06T06:44:00.000 | python,pyscripter | Command to clean screen in PyScripter? | 0 | 1 | 3 | 15,842,157 | 1 |
0 | 0 | I'm developing a GUI with PyQt. The GUI has a qListWidget, a qTableWidget, and a plot implemented with Mayavi. The list refers to shapes that are plotted (cylinders and cones for example). When a shape is selected in the list, I want the shape's properties to be loaded into the table (from a dictionary variable) and the shape to be highlighted in the plot. I've got the Mayavi plotting working fine. Also, if the table is edited, I need the shape to be re-plotted, to reflect the new property value (like for a cylinder, if the radius is changed).
So, when a list item is selected -> update the table with the item's properties (from a dictionary variable), highlight the item on the plot
When the table is edited -> update the dictionary variable and re-plot the item
The Problem: when I select a list item and load data into the table, the qTableWidget ItemChanged signal fires every time a cell is updated, which triggers re-plotting the shape numerous times with incomplete data.
Is there a typical means of disabling the GUI event loop while the table is being programmatically updated? (I have experience with Excel VBA, in that context setting Application.EnableEvents=False will prevent triggering a WorksheetChange event every time a cell is programmatically updated.)
Should I have a "table update in progress" variable to prevent action from being taken while the table is being updated?
Is there a way to update the Table Widget all at once instead of item by item? (I'll admit I'm intentionally avoiding Model-View framework for the moment, hence the qListWIdget and qTableWidget).
Any suggestions?
I'm a first time poster, but a long time user of StackOverflow, so I just want to say thanks in advance for being such an awesome community! | false | 13,771,694 | 0 | 0 | 0 | 0 | If you disable the entire event loop, the app becomes unresponsive. And, even if the user doesn't notice, the OS might, and put up some kind of "hang" notification (like OS X's brightly-colored spinning beachball, which no user will ever miss).
You might want to disable repaints without disabling the event loop entirely. But even that's probably too drastic.
All you're really trying to do is make sure the table stops redrawing itself (without changing the way you've implemented your table view, which you admit isn't ideal, but you have reasons for).
So, just disable the ItemChanged updates. The easiest way to do this, in almost every case, is to call blockSignals(True) on the widget.
In the rare cases where this won't work (or when you're dealing with ancient code that's meant to be used in both Qt4-based and earlier projects), you can still get the handler(s) for the signal, stash them away, and remove them, then do your work, then restore the previous handler(s).
You could instead create a flag that the handlers can access, and change them so they do nothing if the flag is set. This is the traditional C way of doing things, but it's usually not what you want to do in Python. | 0 | 13,515 | 0 | 9 | 2012-12-07T22:01:00.000 | python,pyqt,pyqt4,qtablewidget | Turn off PyQt Event Loop While Editing Table | 0 | 1 | 3 | 13,772,005 | 1 |
0 | 0 | I have installed Qt designer 4.8.2, Pyside, and Python 3.3. When I create a form with Qt designer I am not able to see the code when clicking on view code. The error message is:"Unable to launch C:\Qt\4.8.2\bin\uic".
I have the pyuic under C:\Python33\Lib\site-packages\PyQt4\uic. Please help. | false | 13,792,502 | 0.141893 | 0 | 0 | 5 | Just create a directory where it search for uic.exe file and copy existing uic.exe file to that directory.
My example :
When I clicked View Code it shows Error asking for file uic.exe in path
C:\python374\Lib\site-packages\pyqt5_tools\Qt\bin\bin
But I found uicexe file is in C:\python374\Lib\site-packages\pyqt5_tools\Qt\bin folder
So I created another bin folder and copied uic.exe into that folder . That solved my problem. | 0 | 22,091 | 0 | 6 | 2012-12-09T22:25:00.000 | python-3.x,qt4,pyside | Unable to Launch Qt uic | 0 | 1 | 7 | 57,644,204 | 1 |
0 | 0 | So I want to practice python on my Android. Is there a way I can get the interpreter or an interpreter emulator on my device? | false | 13,793,158 | 0 | 0 | 0 | 0 | Download PyDroid 3 from Playstore and if you like it buy the pro version. It costs around 2$ but you have all you need to do Python 3 programming | 0 | 28,974 | 0 | 7 | 2012-12-09T23:49:00.000 | android,python | Python Interpreter on Android | 0 | 1 | 4 | 54,814,139 | 1 |
0 | 0 | In one of my software, I use AuiManager to manage all the different parts of the UI. Now, I start to use FoldPanelBar in one of the AuiPane. At first, I changed part of the Panel to use FoldPanelBar, and the bar is layout with others using BoxSizer. But it doesn't function correctly as the window is resized. Then I moved all the different controls in the Panel into the FoldPanelBar and make the bar the only control of the panel (No sizers anymore). But the FoldPanelBar still don't resize. Do you know why? Thanks. | false | 13,815,107 | 0 | 0 | 0 | 0 | After some investigation, I have solved this problem by myself. Though FoldPanelBar doesn't play well with others in a Sizer, if it's the only one in a sizer, it works. weird. | 0 | 109 | 0 | 0 | 2012-12-11T06:55:00.000 | wxpython | Resize FoldPanelBar in AuiManager | 0 | 1 | 1 | 13,878,574 | 1 |
0 | 0 | My wx GUI shows thumbnails, but they're slow to generate, so:
The program should remain usable while the thumbnails are generating.
Switching to a new folder should stop generating thumbnails for the old folder.
If possible, thumbnail generation should make use of multiple processors.
What is the best way to do this? | true | 13,830,557 | 1.2 | 0 | 0 | 4 | Putting the thumbnail generation in a background thread with threading.Thread will solve your first problem, making the program usable.
If you want a way to interrupt it, the usual way is to add a "stop" variable which the background thread checks every so often (e.g., once per thumbnail), and the GUI thread sets when it wants to stop it. Ideally you should protect this with a threading.Condition. (The condition isn't actually necessary in most cases—the same GIL that prevents your code from parallelizing well also protects you from certain kinds of race conditions. But you shouldn't rely on that.)
For the third problem, the first question is: Is thumbnail generation actually CPU-bound? If you're spending more time reading and writing images from disk, it probably isn't, so there's no point trying to parallelize it. But, let's assume that it is.
First, if you have N cores, you want a pool of N threads, or N-1 if the main thread has a lot of work to do too, or maybe something like 2N or 2N-1 to trade off a bit of best-case performance for a bit of worst-case performance.
However, if that CPU work is done in Python, or in a C extension that nevertheless holds the Python GIL, this won't help, because most of the time, only one of those threads will actually be running.
One solution to this is to switch from threads to processes, ideally using the standard multiprocessing module. It has built-in APIs to create a pool of processes, and to submit jobs to the pool with simple load-balancing.
The problem with using processes is that you no longer get automatic sharing of data, so that "stop flag" won't work. You need to explicitly create a flag in shared memory, or use a pipe or some other mechanism for communication instead. The multiprocessing docs explain the various ways to do this.
You can actually just kill the subprocesses. However, you may not want to do this. First, unless you've written your code carefully, it may leave your thumbnail cache in an inconsistent state that will confuse the rest of your code. Also, if you want this to be efficient on Windows, creating the subprocesses takes some time (not as in "30 minutes" or anything, but enough to affect the perceived responsiveness of your code if you recreate the pool every time a user clicks a new folder), so you probably want to create the pool before you need it, and keep it for the entire life of the program.
Other than that, all you have to get right is the job size. Hopefully creating one thumbnail isn't too big of a job—but if it's too small of a job, you can batch multiple thumbnails up into a single job—or, more simply, look at the multiprocessing API and change the way it batches jobs when load-balancing.
Meanwhile, if you go with a pool solution (whether threads or processes), if your jobs are small enough, you may not really need to cancel. Just drain the job queue—each worker will finish whichever job it's working on now, but then sleep until you feed in more jobs. Remember to also drain the queue (and then maybe join the pool) when it's time to quit.
One last thing to keep in mind is that if you successfully generate thumbnails as fast as your computer is capable of generating them, you may actually cause the whole computer—and therefore your GUI—to become sluggish and unresponsive. This usually comes up when your code is actually I/O bound and you're using most of the disk bandwidth, or when you use lots of memory and trigger swap thrash, but if your code really is CPU-bound, and you're having problems because you're using all the CPU, you may want to either use 1 fewer core, or look into setting thread/process priorities. | 1 | 155 | 0 | 0 | 2012-12-11T23:57:00.000 | python,multithreading,user-interface,wxpython | Python: Interruptable threading in wx | 0 | 1 | 1 | 13,830,881 | 1 |
0 | 0 | I got curious and have been reading about GUI development using Python for the past hour. After reading documentation of wxPython, PyQt, Nokia's Python bindings for Qt along with Tkinter a question came to my mind.
When I create a console application with Python, it runs using the embedded Python interpreter (which I assume is usually if not always in my case cpython).
So I was wondering, what's the case with these "widget toolkits"?
How is the Python code executed and what interprets it (or executed it)?
Which part of my Python code is interpreted using the Python
interpreter?
Or does the Python code get lexically analysed and then parsed by the widget's
toolkit which then interpretes and executes (or compile during build)?
I am looking forward to understanding what goes on in the background in comparison with Python applications' (a bit simpler to understand) interpretation with the Python interpreter.
Thank you.
PS. To whichever genius thinks that this question deserves to be closed;
A lot of people wonder the internals of external libraries and systems. Especially those which are not as simple as they look. There currently is not any question explaining this on SE. | true | 13,867,475 | 1.2 | 0 | 0 | 8 | This is just a really generalized high-level explanation about "GUI toolkits"...
Lets say you decide to use the Qt framework. This framework is written in C++. There are two different python bindings that can be used, allowing one to write a GUI application in python against the same API as the C++ version.
The python bindings provide a wrapping around calls into the C++ code. PyQt4 for instance uses sip, while PySide uses shiboken. These are just language wrapping tools that take specifications for how to map between the C++ objects and their intended python interface.
Ok, so you start using PyQt... All of the code you write has to pass through the python interpreter. Some of it may be pure python. Some of it will call into C++ libs to create things like your widgets. In Qt, there will be a C++ pointer associated with the python instance counterpart.
It is the C++ layer that is then communicating with the window manager of your platform, to turn platform-independent API calls into something platform specific, like how to exactly draw a button or menu.
Whether you create a console only or GUI based python application, it all goes through the python interpreter to interpret your python code. Something must interpret the python language for you. | 0 | 1,387 | 0 | 3 | 2012-12-13T19:58:00.000 | python,user-interface,wxpython,tkinter,pyside | How is Python interpreted with wxPython, PyQt, PySide or Tkinter? | 0 | 1 | 1 | 13,867,619 | 1 |
0 | 0 | I want to write a program that asks the user a series of questions in different dialog boxes. Each box shows up one at a time, and goes to the next box if the button next is clicked. My question is do I create a class for each Dialog and just call the next class once the button next is clicked? Or is there a more elegant solution to this? | false | 13,873,190 | 0 | 0 | 0 | 0 | Are you sure you have to create a class for a Dialog? Isn't Tkinter built-in dialog class ok?
You could provide an iterator of Dialogs to a next() function, which every Next button would call when clicked. Did you mean something like that? | 0 | 1,732 | 0 | 2 | 2012-12-14T05:27:00.000 | python,user-interface,python-2.7,tkinter,gui-designer | How to design GUI sequence in Tkinter with Python 2.7 | 0 | 1 | 2 | 13,875,940 | 1 |
0 | 0 | I am using Windows 7 (32bit).
As a programming exercise, I have to make a reminder using tkinter.
To be more specified :
My main project is to help people who suffer from alzheimer disease.
So, one of my targets is to make a reminder for helping them do the necessary activities/things.
For example,
At 14:00 o'clock, create a messagebox (and if it possible play a sound)..saying "It's time to eat".
Then at 18:00 o'clock, create a messagebox (and if it possible play a sound)..saying "It's time for a walk".
etc...
How I can do this?
Is there a special module or some tools in python(or in tkinter) that can help me?
Before, coding in Visual Basic as remember I used something like "Timer"..But I can't remember more about this.. :P
Thanks in advance. | false | 13,875,641 | 0 | 0 | 0 | 0 | At first thought you can have a tk config dialog, where you can add new rules, edit messagebox strings etc. Then you will have in which you will use the time module. From there you can access the system time.
If you want to display windows messageboxes, you can find them in the ctypes libary. | 1 | 292 | 0 | 3 | 2012-12-14T09:13:00.000 | python,time,tkinter | Reminder Using Tkinter | 0 | 1 | 2 | 13,875,712 | 1 |
0 | 0 | Is it possible to run my program inside Tkinter?
I have a program which fits the curves. I want to make it GUI and looking for the ways to insert it into Tkinter.
I want my program to run after clicking a BUTTON widget. Is there a option in Tkinter to run another file.py? | false | 13,877,727 | 0 | 0 | 0 | 0 | To run another file, you can import it, or load the data with
file = open("filename.txt", "r")
then use
exec(string)
to run the program inside it. | 0 | 2,372 | 0 | 2 | 2012-12-14T11:23:00.000 | python,tkinter | Run my program inside Tkinter program | 0 | 1 | 2 | 13,877,837 | 1 |
0 | 0 | How can I have the wxPython notebooks tabs be center on the top?
EXTRA TEXT TO MAKE IT LOOK LONGER EVER THOUGH IT IS A SIMPLE QUESTION. | true | 13,898,391 | 1.2 | 0 | 0 | 1 | Notebook tabs always start off in the top left for the native widget. The only thing you can change is which side the tabs appear on (i.e. top, left, bottom or right). You cannot control where on the side they appear.
You might be able to take FlatNotebook and hack it a bit to add this functionality since it is written in pure Python versus wx.Notebook which is wrapped C++. | 0 | 106 | 0 | 0 | 2012-12-16T03:38:00.000 | wxpython | wxPython notebook have tabs be center top? | 0 | 1 | 1 | 13,918,810 | 1 |
0 | 0 | I want to get the content of DataWindow from PBL (PowerBuilder Library) file and edit it in place. The idea is to read the pbl file, and access individual DataWindows to modify source code. Somehow, I have managed to do the first part with PblReader .NET library using IronPython. It allows me to read PBL files, and access DataWindow source code. However it doesn't support modifications. I would like to know if anyone have an idea for editing PBL files? | true | 13,920,682 | 1.2 | 0 | 0 | 1 | A PowerBuilder application can load a DataWindow from a PBL (doesn't have to be in the library path), modify it, and save it back to the PBL. I've written a couple of tools that do that. PowerBuilder will allow you to modify the DataWindow according to its object model using the modify method. I don't know why anyone would want to reinvent all of this. I recall seeing Python bindings for PB somewhere. You could get the DW syntax from PB, call out to Python, then save it back in PB. But you'd have to do all the parsing in Python, whereas PB already understands the DW. Finally I'm surprised Terry didn't plug PBL Peeper. You could use PBL Peeper to export the DataWindows, massage them to your hearts's content in Python. then import them back into PB. | 1 | 3,599 | 0 | 1 | 2012-12-17T19:19:00.000 | python,.net,powerbuilder | idea/solution how to edit PBL (PowerBuilder Library) files? | 0 | 1 | 1 | 13,943,263 | 1 |
0 | 0 | This is my first question ever so bear with me!
Currently in my program, I have a parent widget which acts as a canvas. The user can add or remove widgets to the parent at run-time. Those widgets are then given an absolute position, that is, they are not positioned by a layout. Once added, a widget can be moved around arbitrarily by the user.
I want the user to be able to select a group of widgets by dragging a box around them. I have already coded the part that displays the rectangle while the user is dragging. Now, I want to be able to retrieve all the widgets within that rectangle (region).
I am aware of the findChild() and findChildren() functions, and they indeed do return the children as they are supposed to. But what I'd really need is a way to limit the search to the boundaries of the region since there will most-likely be quite a lot of widgets within the 'canvas'. (There could be thousands of widgets spread over a very large area due to the nature of what I'm doing!)
Here is my question: What would be my best option? Should I just go ahead and use findChildren() and loop through the list to find the children within the region manually. Or should I loop through all the pixels within the region using findChild(x, y)? Or perhaps there is an even simpler solution that would speed up the process? Something along the lines of findChildren(x, y, width, height)?
Hopefully my question made sense. I tried to explain things as best as I could. Thanks! | true | 13,924,980 | 1.2 | 0 | 0 | 3 | If you had used QGraphicsScene instead of rolling your own, you could have used the items(..) methods to very efficiently find your children in a particular area.
It's only possible in QGraphicsScene because it uses a BSP spatial acceleration structure, so if you cannot migrate to QGraphicsScene in a reasonable amount of time - you are going to have write your own. It's not as hard as it sounds, I've written numerous bounding volume hierarchy structures and they're quite straightforward. | 0 | 493 | 0 | 3 | 2012-12-18T01:26:00.000 | python,qt,pyqt | Qt: get all children within region of the parent | 0 | 1 | 1 | 13,928,629 | 1 |
0 | 0 | I`m using pyPdf to crop pdf pages.
And the only thing i miss, is GUI for this script.
I picked up tkinter module to do the GUI, but i cannot find whether it is possible to display pdf pages with GUI created with tkinter.
Any thoughts ?
Thank you. | false | 13,934,268 | 0.099668 | 0 | 0 | 1 | Tkinter has no support for displaying pdf. | 0 | 2,722 | 0 | 1 | 2012-12-18T13:39:00.000 | python,python-2.7,tkinter,pypdf | display pdf pages with GUI on tkinter | 0 | 1 | 2 | 13,934,811 | 1 |
0 | 0 | I've wrapped a C++ class using Boost.Python. These Objects have strong references (boost::shared_ptr) on the C++-side, and there may be intermittent strong references in Python as well. So far, everything works well. However, if I create a python weak reference from one of the strong references, this weak reference is deleted as soon as the last python strong reference disappears. I'd like the weak reference to stay alive until the last strong reference on the C++ side disappears as well. Is it possible to achieve that?
Phrased another way: Is there a way to find out from python if a particular C++ object (wrapped by Boost.Python) still exists? | false | 13,956,055 | 0.197375 | 1 | 0 | 1 | How are you holding a "C++ strong reference" to the wrapped class ?
I'm quite rusty on boost python, but I believe it's the boost::shared_ptr's deleter presence which ensures lifetime management.
If that isn't the problem, you probably need to hold the instance in C++ in a boost::python::object. | 0 | 241 | 0 | 6 | 2012-12-19T15:49:00.000 | c++,python,boost-python | Boost.Python: Getting a python weak reference to a wrapped C++ object | 0 | 1 | 1 | 13,989,547 | 1 |
Subsets and Splits