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'm trying to maintain 2 python projects. one of them is using PyQt4 and another one is using PyQt5. So I created 2 virtualenv as follow. 1) installed virtualenv and virtualenvwrapper by sudo 2) logout from root(sudo) 3) created virtualenv at /home/thura/workspace/python/virtualenv 4) mkvirtualenv gui_pyqt4 under /home/thura/workspace/python/virtualenv 5) mkvirtualenv gui_pyqt5 under /home/thura/workspace/python/virtualenv And I want to install the lib/module/etc of PyQt4 into gui_pyqt4 and install the lib/module/etc of PyQt5 into gui_pyqt5. I tried to install "pip install python-qt4" and "pip install python-qt5" but not working. How can I install different module into different environment.?
false
20,833,826
0
0
0
0
You need to activate the appropriate virtual environment and then use the command pip install PyQt4or pip install PyQt5. Since you are using virtualenvwrapper, the virtual environment is activated automatically. Otherwise, use workon virtualenv_name to activate the environment.Do tell if the problem still persists.
1
1,320
0
0
2013-12-30T05:27:00.000
python,python-2.7
How to install PyQt4 and PyQt5 at different virtualenv?
0
1
2
47,946,736
1
0
0
I have two objects troll and pig. I'm detecting collisions between these two characters with Pygame's colliderect function. collisions for this works perfectly, however I am unable to remove the object from the screen when a collision occurs. When a troll collideswith a pig, I want the pig to disappear from the screen. I set an image for both of these and bit them, is there a way to un-blit? Ive tried pygame.image.set_alpha(255) (which set full transparency of an image) function to no avail. Any suggestions?
false
20,839,246
0
0
0
0
Can't you just stop drawing the pig? Each frame you fill the screen with the background, so it won't be visible.
0
489
0
0
2013-12-30T12:07:00.000
python,pygame,sprite
remove object after collision
0
1
1
20,843,239
1
0
0
I'm looking for some advice mainly here. I'm working on an application, where the main processing (stored on a server) is carried out in C++ and the GUI (front-end) is carried out in Python. These two programs will communicate with each other. The Python will send across the files needed for the C++ program to work, and give the C++ program some data to work with.. The back-end will then communicate back with the processed data. Would therefore it be better to use Sockets? I thought about completing this using text files, but, have gone off this idea, instead will just save the data as a .txt file so it can be opened up in future instances. Also, if I was to use sockets, would there be any conflict in using Python/C++? Any help or advice would be greatly appreciated.
false
20,839,944
0
0
0
0
I would go for named pipes, would be readily available in your circumstance because it is just similar to reading and writing to file, but it also has features similar to sockets i.e. you can make them communicate on a network (different hosts)
0
3,600
0
4
2013-12-30T12:50:00.000
c++,python,sockets
Sending/Receiving data between two different programs
0
1
4
20,840,334
1
1
0
I want to publish an Android application that I have developed but have a minor concern. The application will load with a database file (or sqlite3 file). If updates arise in the future and these updates are only targeting the application's functionality without the database structure, I wish to allow users to keep their saved entries in their sqlite3 files. So what is the best practice to send updates? Compile the apk files with the new updated code only and without the database files? Or is there any other suggestion? PS: I am not working with Java and Eclipse, but with python for Android and the Kivy platform which is an amazing new way for developing Android applications.
false
20,856,465
0
0
1
0
if you're using local sqlite then you have to embed the database file within the app as failure to do so it means there's no database, in case for updates database have version numbers where as it can not upgrade the database provided the version number is the same as the previous app updates
0
487
0
4
2013-12-31T11:14:00.000
android,python-2.7,sqlite,apk,kivy
Update apk file on Google Play
0
2
2
20,856,571
1
1
0
I want to publish an Android application that I have developed but have a minor concern. The application will load with a database file (or sqlite3 file). If updates arise in the future and these updates are only targeting the application's functionality without the database structure, I wish to allow users to keep their saved entries in their sqlite3 files. So what is the best practice to send updates? Compile the apk files with the new updated code only and without the database files? Or is there any other suggestion? PS: I am not working with Java and Eclipse, but with python for Android and the Kivy platform which is an amazing new way for developing Android applications.
false
20,856,465
0
0
1
0
I had the same issue when I started my app but since kivy has no solution for this I tried to create a directory outside my app directory in android with a simple os.mkdir('../##') and I put all the files there. Hope this helps!
0
487
0
4
2013-12-31T11:14:00.000
android,python-2.7,sqlite,apk,kivy
Update apk file on Google Play
0
2
2
46,767,741
1
0
0
I want to call a python/pygame program from inside another. I do this with the os.startfile(minigame1) command. But when the program launches it first runs a python command line window and then opens the minigame in a seperate window. How can I make both programs share the same pygame window? Thank you in advance
false
20,861,890
0
0
0
0
If it is at all possible for two instances of a Pygame program to share a common display, then try using pygame.display.get_surface() to get the display surface- this will return None if the display isn't already initialized. Another issue you will have to overcome in your project is the fact that calling pygame.event.get() (or a similar method) in one program will hide it from the other, so you will have to share the pygame.event.Events between the two programs. This would only work if you can get the two programs to share the same window though; if Pygame's written so that separate Python processes will have separate Pygame windows, then I doubt you'll be able to get around that without changing up the Pygame source.
0
296
0
0
2013-12-31T18:41:00.000
python,pygame
Two python/pygame programs to run in the same window
0
1
1
20,862,261
1
0
0
I'm very new in the python world I know some about command line commands and gui commands. I've already succeeded in writing a working python script for Abaqus and now I want to add some GUI in it instead of changing the parameters in the text file everytime. I discovered GUI Toolkit but it seems to difficult, for two reasons: 1) it doesn't seem to be portable; 2) I don't really like the code written by someone else, especially because most of the times it adds things that I don't understand and gives me error that I can't fix, maybe because the GUI Toolkit interface is not complete. Here's my question. Can I use python tk GUI for abaqus? Is there anyone who has tried it and can share some simple codes. Thanks for the help
false
20,883,944
0
0
0
0
I have used tk GUIs with Abaqus but I find they don't ingrate that well and end up causing all sorts of strange errors (eg ignoring text input, windows hanging etc). If you are used to tk its not that much of a leap with the FX & AFX routines. I didnt know about RSG though and just had a quick play, liking it.
0
3,171
0
0
2014-01-02T13:20:00.000
python,user-interface
Is it possible to use python GUI instead of Abaqus GUI Toolkit?
0
2
3
29,543,626
1
0
0
I'm very new in the python world I know some about command line commands and gui commands. I've already succeeded in writing a working python script for Abaqus and now I want to add some GUI in it instead of changing the parameters in the text file everytime. I discovered GUI Toolkit but it seems to difficult, for two reasons: 1) it doesn't seem to be portable; 2) I don't really like the code written by someone else, especially because most of the times it adds things that I don't understand and gives me error that I can't fix, maybe because the GUI Toolkit interface is not complete. Here's my question. Can I use python tk GUI for abaqus? Is there anyone who has tried it and can share some simple codes. Thanks for the help
false
20,883,944
0.197375
0
0
3
I am no expert in the topic, but I do have some experience with writing plug-ins for Abaqus. You may want to look into using the RSG (Really Simple GUI) Dialogue Builder. It is under the plug-ins options on the Abaqus toolbar. The RSG is a GUI for building GUIs based on Abaqus's customized version of the FOX Toolkit. It is limited compared to programming the GUI yourself, but has plenty of options for creating some useful plug-ins. I generally start writing a plug-in by using the RSG to develop the base layout of my GUI. If there are options that I wish to include in my GUI that are not included in the RSG, I just edit the python files generated by the RSG. Responding to your original question about whether or not you can use tk in Abaqus; I have run scripts in Abaqus that calls for the tk file browser and it has worked successfully. I don't see why you wouldn't be able to register the plug-in using the FOX Toolkit and then call tk to open a GUI. Hope this helps. I know this is an old question, but the responses were weak. Additionally, I know how hard it can be to find good help/information on Abaqus scripting.
0
3,171
0
0
2014-01-02T13:20:00.000
python,user-interface
Is it possible to use python GUI instead of Abaqus GUI Toolkit?
0
2
3
24,072,899
1
0
0
I installed the SimpleCv on my raspberryPi and the driver to use the camera board with it (uv4l driver) and now I'd like to play with it. When I type on simpleCV shell "Camera(0).getImage().save("foo.jpg") " , on the screen appears the camera preview and I am not able to type other command because this preview covers the shell What Have I to do to remove the camera preview ? Thanks a lot ! Filippo
true
20,891,900
1.2
1
0
3
Try the nopreview option pkill uv4l uv4l --driver raspicam --auto-video_nr --encoding yuv420 --width 320 --height 240 --nopreview export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so Hope that helps
0
3,614
0
0
2014-01-02T21:07:00.000
python,linux,opencv,raspberry-pi,simplecv
How remove camera preview to raspberry pi
0
1
2
20,910,789
1
0
0
There's one file which is run with Python33, it has this line of code: `os.startfile(r'rungame\xsim.py')` That opens up a file in Python32, called xsim.py, and that works fine. However, xsim, which uses pygame modules, does not run as it would usually run. It cannot load its images when accessed this way, the first image is 'winp.png', and it is in the same folder as xsim.py (rungame). Here is the code which loads it: `pygame.display.set_icon(pygame.image.load('winp.png'))`
false
20,914,146
0
0
0
0
The problem has been fixed. The current working directory was the location of the first file, not the file in need of the pictures which was inside the folder 'rungame', so that is where it looked for winp.png when no path was specified.
0
56
0
0
2014-01-03T22:50:00.000
python,path,pygame
Pygame image loading error when accessing Python through another Python file
0
1
1
20,914,612
1
0
0
Not sure what else to call 'active'. Is it possible to have the scrollbar, once clicked on to remain 'active'? Another words once I click on the scrollbar I would like to be able to move the scrollbar with the keyboard(left/right arrow keys) or the mouse. Is this possible? If so what do I have to do to accomplish it?
false
20,939,891
0.099668
0
0
1
Technically it should be possible, by giving the scrollbar the keyboard focus and then adding some custom bindings. That's a fairly unusual thing to do. Since the scrollbars are drawn with native widgets on Windows and the Mac, it might be impossible on those platforms. What you probably want to do instead is set some bindings on the application as a whole, or on some sort of widget that typically gets focus such as a canvas or text widget. Your bindings can call the xview and yview commands and give it arguments to tell it how to scroll, which is exactly what the scrollbar does.
0
536
0
0
2014-01-05T22:13:00.000
python,tkinter
Python tkinter scrollbar active state
0
1
2
20,940,725
1
0
0
I am looking for a PyQt5 tutorial. It is rather complicated to start GUI development with Python for the first time without a tutorial. I only found some PyQt4 tutorials so far, and since something changed from Qt4 to Qt5, for example the fact SIGNAL and SLOT are no more supported in Qt5, it would be nice to have specific tutorials for PyQt5. Can someone please provide a tutorial on how to start GUI development with PyQt5?
false
20,996,193
1
0
0
29
Been looking for PyQt5 tutorials for some time? Look no further! You won't find many around the internet. Not really tutorials, but pretty self-explanatory basic scripts under the following path: /python/lib/site-packages/PyQt5/examples you will find about 100 examples in 30 folders ranging from beginner to advanced, covering basic windows, menus, tabs, layouts, network, OpenGL, etc.
0
57,823
0
65
2014-01-08T12:51:00.000
python,user-interface,qt5,pyqt5
Is there a tutorial specifically for PyQt5?
0
1
3
21,359,084
1
0
0
I downloaded the sources for Android NDK from the git repository, I noticed that the sources for perl and python are bundled with the other dependencies: what are this 2 interpreters for ? Does this means that I can build python for Android with the NDK ? Or that if I have a python application I can port it to Android with the NDK ?
true
21,006,620
1.2
1
0
2
Python and perl are used internally by NDK tools to make the cross-compile environment more friendly. You only need them on the host. NDK can be built for Windows, Mac, or Linux. So the git repository contains all opensource that is required to compile NDK for any of these platforms.
1
155
0
1
2014-01-08T21:12:00.000
android,python,git,perl,android-ndk
Why do I get python and perl with the NDK sources?
0
1
1
21,015,004
1
0
0
I need to get the channel of wx.bitmap. I use the function GetDepth. It return 24 all the time , even if I pass a 8depth gray image
true
21,013,186
1.2
0
0
0
I use PIL(python image library)'s mode to judge the channels
0
38
0
0
2014-01-09T06:35:00.000
python,wxpython
How to get the channel of a image by wx.bitmap
0
1
1
21,225,163
1
0
0
The question is pretty much in the title, not much to add here. I'm trying to allow the user to dynamically size multi-line text controls just as they can re-size the panel (I set the default, but they are free to change it). Can this be done?
false
21,047,039
0.197375
0
0
2
Take a look at wx.lib.resizewidget and the ResizeWidget sample in the demo.
0
119
0
0
2014-01-10T14:37:00.000
python,wxpython
Is there a way to allow the user to re size a text control in wxPython?
0
1
2
21,067,422
1
0
0
I am reading through "Making games with Python & Pygame" and I have noticed that because the author uses lots of functions with drawing in to break his code up, he uses lots of globals such as GRIDSIZE or BACKGROUNDCOLOR. I was always told that globals were generally bad, but without them, every drawing function would have ten more, repeating parameters - and I have also been told that repetition is bad. I wondered, then, is the author is correct in using globals for parameters that appear in most (drawing) functions, or should have just used more, repetitive parameters.
false
21,054,775
0.039979
0
0
1
Example code in books is not the same as production code Code in books and articles explaining things do things to keep to the point and not inundate the reader with what might be noise or tangents to the specific topic. The author is taking short cuts to keep the code as specific to the problem they are explaining as possible. That said, there are better ways to do what they are doing than using module level variables. Even in books and tutorials. Huge State Machines are Bad Variables that encompass too much scope, no matter what level they are at, tend to have the side effect of creating invisible side effects that manifest themselves from the huge state machine that the application becomes. Excessive parameters to functions is a code smell It should tell you that you probably need to encapsulate your data better. Multiple related parameters should be grouped into a single data structure and just pass that single data structure as a parameter.
1
189
0
2
2014-01-10T21:32:00.000
python,pygame
Globals vs Parameters for Functions with the Same Parameters
0
4
5
21,054,996
1
0
0
I am reading through "Making games with Python & Pygame" and I have noticed that because the author uses lots of functions with drawing in to break his code up, he uses lots of globals such as GRIDSIZE or BACKGROUNDCOLOR. I was always told that globals were generally bad, but without them, every drawing function would have ten more, repeating parameters - and I have also been told that repetition is bad. I wondered, then, is the author is correct in using globals for parameters that appear in most (drawing) functions, or should have just used more, repetitive parameters.
false
21,054,775
0.039979
0
0
1
Constant globals can be OK, despite whatever general warnings you may have heard. In Python "constant" means "named in capital letters as a hint that nobody should modify them", and "globals" means "module-level variables", but the principle still applies. So hopefully GRIDSIZE and BACKGROUNDCOLOR are constant for the duration of the program, but it's possible they are not: I haven't seem the code. There are plenty of examples of module-level constants in the standard Python libraries. For example errno contains E2BIG, EACCESS, etc. math contains math.pi. However, those examples are even more constant than GRIDSIZE. Presumably it could change between different runs of the same program, which math.pi will not. So you need to assess the consequences of this particular global, and decide whether to use it or not. I was always told that globals were generally bad Bad things are bad for reasons, not "generally bad". In order to decide what to do you need to understand the reasons. Using globals (or, in Python, module-scope objects) causes certain problems: dependencies on previously-executed code: this is the worst problem, but it applies only to mutable globals. If you use a global that can be modified elsewhere, then in order for someone reading the code to reason about its current value they might need to know about the whole program, because any part of the program might access the global. If you keep your mutables in an object that only parts of your code ever get to see, then you only have to reason about those parts of your code that interact with that object. This might not sound like a big difference if your program is one file that's 100 lines long, but it becomes one eventually. Making your code easy to work with is almost all about making it easy for a reader to reason about what the code does. What else can affect it is a big part of that, so this is important. And "a reader" is you, next time you want to change something, so helping out "readers" of your code is pure self-interest. dependencies on concurrently-executing code: mutable globals + threads = needs locks = effort. hidden dependencies: this is applicable even for constants. You have to decide whether it's OK for this bit of code to have some dependencies that are not supplied as parameters ("injected") by the caller of that code. Almost always the answer to this question is "yes". If it is "absolutely not" then you're in a tight spot if you dislike lots of parameters, because you wouldn't even use Python builtins by name, let alone names from modules the code imports. Having decided that it's OK to have hidden dependencies, you have to think about the consequences of GRIDSIZE being one of them, on the way you use and especially test the code. Provided that you don't want to draw on different-sized grids in the same program you're basically fine until you want to write tests that cover lots of different values of GRIDSIZE. You'd do that to give yourself confidence now that when you change GRIDSIZE later nothing will break. At that point you'd probably want to be able to provide it as a parameter. For this reason you might find it more useful to have parameters with defaults rather than global values. To prevent long repetitive parameter lists you might pass around one object that combines all of these settings rather than each separately. Just beware of creating an object with multiple unrelated purposes, because the others are distracting if you want to reason about just one. namespace pollution: relevant in C, if you don't use static then two completely unrelated files cannot have different functions of the same name. Not so relevant in Python where everything is in namespaces.
1
189
0
2
2014-01-10T21:32:00.000
python,pygame
Globals vs Parameters for Functions with the Same Parameters
0
4
5
21,056,248
1
0
0
I am reading through "Making games with Python & Pygame" and I have noticed that because the author uses lots of functions with drawing in to break his code up, he uses lots of globals such as GRIDSIZE or BACKGROUNDCOLOR. I was always told that globals were generally bad, but without them, every drawing function would have ten more, repeating parameters - and I have also been told that repetition is bad. I wondered, then, is the author is correct in using globals for parameters that appear in most (drawing) functions, or should have just used more, repetitive parameters.
false
21,054,775
0.039979
0
0
1
In Python you don't have as big a problem with globals, because Python globals are at the module level. (So global is a bit of a misnomer anyway.) It's fine to use module-level globals under many circumstances where true globals would be inappropriate.
1
189
0
2
2014-01-10T21:32:00.000
python,pygame
Globals vs Parameters for Functions with the Same Parameters
0
4
5
21,054,846
1
0
0
I am reading through "Making games with Python & Pygame" and I have noticed that because the author uses lots of functions with drawing in to break his code up, he uses lots of globals such as GRIDSIZE or BACKGROUNDCOLOR. I was always told that globals were generally bad, but without them, every drawing function would have ten more, repeating parameters - and I have also been told that repetition is bad. I wondered, then, is the author is correct in using globals for parameters that appear in most (drawing) functions, or should have just used more, repetitive parameters.
false
21,054,775
0
0
0
0
It depends on the situation. Globals are not generally bad, but should be avoided if not absolutely necessary. For example, constants are perfectly ok as globals, while configuration data should be bundled (encapsulated) as much as possible. If you concentrate all such data onto one (or few) objects, you either might want to have the named functions as methods of the objects's class(es), or you might want to access these objects from within these functions. At the end, it is a matter of taste. If you think that things are handlable in a convenient way, let it be as it is. If it looks like confusion, better change it.
1
189
0
2
2014-01-10T21:32:00.000
python,pygame
Globals vs Parameters for Functions with the Same Parameters
0
4
5
21,054,871
1
0
0
At the moment I'm using Visual Studio 2012 Professional with Python Tools to program application for my Raspberry Pi. For the moment this is a brilliant combination, because the application can also run on a Windows computer and debug it while in development. After I'm at a point that the application can run on my Pi then I will move the files to the Pi and run it there. Although today I received a GPIO cable and this open new possibilities to use buttons and controle lightswitches, thus fun stuff. But! Now the problem, on my Windows machine I can use the GPIO library and not see the results of the application, what happens if I push this button, what happens in the code, I really want to debug this and also when using in a bigger application. Everytime moving the files to the Pi and testing them there is not a option. Is there a application that can simulate the GPIO interface of the Pi on my Windows machine so I can test/debug the application while developing?
false
21,064,985
-0.379949
1
0
-2
The nusbio device can give 8 gpios for your Windows machine directly avaialble for .NET languages.
0
3,513
0
1
2014-01-11T16:45:00.000
python,visual-studio,raspberry-pi,gpio
Program Raspberry PI GPIO on Windows
0
1
1
34,752,703
1
0
0
I have a form (wx.Frame) in which the widest element is the toolbar (created with toolbar = self.CreateToolbar() and toolbar.Realize()). I want the width of the form to be such that every toolbar item is shown. I don't see the toolbar changing after creation, but I'd prefer if that could be handled. Any suggestions? (I'm running Python 2.7, with non-Phoenix wxPython)
false
21,074,285
0
0
0
0
You'll have to figure out what the width of a toolbar item is. Then you can take that number and multiply it by the number of toolbar items and set the frame's size appropriately. Then when you add or remove a toolbar item, part of that process will be to update the size of the frame (SetSize()). You will probably need to call the frame's Layout() method after adding/removing the widget. You may also need to call Refresh().
0
135
0
0
2014-01-12T11:52:00.000
python-2.7,user-interface,wxpython
Set width of wxPython Frame based on toolbar width
0
1
1
21,093,804
1
0
0
I have a listbox on a GUI in Tkinter. I would like to implement a routine where if a listbox item is selected a function is called (based on this selection) to modify the gui (add another adjacent listbox). Then if that selection changes, the gui reverts back to its default view. Can this be done? Seems you would need to associate a function to a listbox selection, not sure how to do this or if its possible... Does anyone have the secret? Its possible to add "select" buttons to the bottom of my listbox, but I wanted to avoid this extra work for user and save space on the GUI. Thanks to all in advance! Daniel
true
21,078,720
1.2
0
0
0
The listbox will fire the virtual event <<ListboxSelect>> whenever the selection changes. If you bind to it, your function will be called whenever the selection changes, even if it was changed via the keyboard.
0
1,733
0
0
2014-01-12T18:40:00.000
python,listbox,tkinter
Calling a function based on a Listbox current selection "curselection()" in Tkinter
0
1
2
21,079,948
1
0
0
It looks like developing GUI applications in HTML+JS with python in the background would be really nice. I see node-webkit. I also see that there are python bindings for webkit. It just seems like it's an order of magnitude more difficult to set up than python/tkinter - and I couldn't find win7 support.
true
21,114,655
1.2
0
0
2
Maybe what you are looking for is Pyjs, is not entirely build to do that, but that's the nearest thing to it I have found.
0
1,465
0
7
2014-01-14T13:23:00.000
python,node-webkit
Is there a python version of node-webkit
0
1
2
21,965,786
1
0
0
A quick question that may seem out of the ordinary. (in reverse) Instead of calling native code from an interpreted language; is there a way to compile Java or Python code to a .dll/.so and call the code from C/C++? I'm willing to accept even answers such as manually spawning the interpreter or JVM and force it to read the .class/.py files. (is this a good solution?) Thank you.
false
21,171,607
0
1
0
0
You can also look into Lua, while not as widely used as a lot of other scripting languages, it was meant to be embedded easily into executables. It's relatively small and fast. Just another option. If you want to call other languages from your c/c++ look into SWIG.
0
253
0
0
2014-01-16T19:58:00.000
java,python,c++,c,dll
Dynamic Link Library for Java/Python to access in C/C++?
0
1
3
21,177,883
1
0
0
How do you get width and height of an image imported into pygame. I got the size using: Surface.get_size , but I dont know how to get the width and height.
true
21,209,496
1.2
0
0
5
There are 2 methods available for getting the width and height of a surface. The first one is get_size(), it returns a tuple (width,height). To access width for instance, you would do: surface.get_size()[0] and for height surface.get_size()[1]. The second method is to use get_width(), and get_height(), which return the width and the height. I suggest going through the python tutorial, to learn more about basic data structures such as tuples.
0
7,226
0
1
2014-01-18T20:31:00.000
python-3.x,pygame
Getting width and height of an image in Pygame
0
1
1
21,209,675
1
1
0
The issue: I have written a ton of code (to automate some pretty laborious tasks online), and have used the mechanize library for Python to handle network requests. It is working very well, except now I have encountered a page which I need javascript functionality... mechanize does not handle javascript. Proposed Solution: I am using PyQt to write the GUI for this app, and it comes packaged with QtWebKit, which DOES handle javascript. I want to use QtWebKit to evaluate the javascript on the page that I am stuck on, and the easiest way of doing this would be to transfer my web session from mechanize over to QtWebKit. I DO NOT want to use PhantomJS, Selenium, or QtWebKit for the entirety of my web requests; I 100% want to keep mechanize for this purpose. I'm wondering how I might be able to transfer my logged in session from mechanize to QtWebKit. Would this work? Transfer all cookies from mechanize to QtWebView Transfer the values of all state variables (like _VIEWSTATE, etc.) from mechanize to QWebView (the page is an ASP.net page...) Change the User-Agent header of QWebView to be identical to mechanize... I don't really see how I could make the two "browsers" appear more identical to the server... would this work? Thanks!
true
21,221,141
1.2
0
0
0
Since nobody answered, I will post my work-around. Basically, wanted to "transfer" my session from Mechanize (the python module) to the QtWebKits QWebView (PyQt4 module) because the vast majority of my project was automated headless, but I had encountered a road block where I had no choice but to have the user manually enter data into a possible resulting page (as the form was different each time depending on circumstances). Instead of transferring sessions, I met this requirement by utilizing QWebViews javascript functionality. My method went like this: Load page in Mechanize, and save the downloaded HTML to a local temporary file. Load this local file in QWebView. The user can now enter required data into the local copy of this page. Locate the form fields on this page, and pull the data the user entered using javascript. You can do this by getting the main frame object for the page (QWebView->Page()->MainFrame()), and then evaluating javascript code to accomplish the above task (use evaluateJavaScript()). Take the data you have extracted from the form fields, and use it to submit the form with the connection you still have open with mechanize. That's it! A bit of a work-around, but it works none-the-less :\
0
384
0
1
2014-01-19T18:57:00.000
javascript,python,asp.net,pyqt,qtwebkit
Python - Transferring session between two browsers
0
1
1
21,532,850
1
0
0
How can I set a suitable fps number in pygame for any kind of monitor running my game? I know I can set fps using pygame.time.Clock().tick(fps) but how can I set suitable fps? Please post example python code along with answer.
false
21,234,884
0.197375
0
0
2
I'm not entirely sure that I understand the question being asked, but I think you will just have to experiment with different numbers and find out what works for you. I find that around 50-100 is a good range. If what you are trying to do is make game events only update a certain number of times per second while rendering happens as fast as the computer is able to handle it, this is a very complex process and probably not very easily done in pygame.
1
603
0
0
2014-01-20T13:02:00.000
python-2.7,pygame,frame-rate
How to set fps in pygame in order to prevent lag?
0
1
2
21,239,429
1
0
0
I have recently published an Android application on Google Play written in Python/Kivy. Normally the "build.py" script would wrap the whole project files into one single folder that is the application package folder. But if i check the content of this package on my phone after the installation of the apk i can find the "android.txt" file, the ".kv/.kv~" file and the ".py~"*and *"pyo" files. My question is: is this safe to expose the source code files or is there something that i am missing in the compilation of my project ? What is annoying me more are the temporary files *.kv~ and .py~ that are exposing the whole project source code.* But i should mention the gratitude and the respect i have for the Kivy project and the Kivy team. Their efforts allowed me to build and publish a nice Android application with Python that i am really proud of. Thank you so much Kivy team.
true
21,252,729
1.2
0
0
3
I have recently published an Android application on Google Play written in Python/Kivy Congratulations. May I ask what app it is? My question is: is this safe to expose the source code files or is there something that i am missing in the compilation of my project ? What is annoying me more are the temporary files .kv~ and .py~ that are exposing the whole project source code. As TwilightSun has explained, some of these files are editor backups, which you can remove or exclude from the apk by modifying your buildozer.spec file or the equivalent python-for-android commands if using that directly. However, more generally, if you are serious about obfuscating your code you will want to take further steps. I'm no expert, but probably this would include things like moving your kv code to a python file (with Builder.load_string) and compiling your whole project with cython. The resulting binaries will be harder to decompile than the python .pyo bytecode that is included by default.
0
1,365
0
3
2014-01-21T08:24:00.000
android,python,kivy
How to hide python code file and other related files in a kivy project
0
2
2
21,260,736
1
0
0
I have recently published an Android application on Google Play written in Python/Kivy. Normally the "build.py" script would wrap the whole project files into one single folder that is the application package folder. But if i check the content of this package on my phone after the installation of the apk i can find the "android.txt" file, the ".kv/.kv~" file and the ".py~"*and *"pyo" files. My question is: is this safe to expose the source code files or is there something that i am missing in the compilation of my project ? What is annoying me more are the temporary files *.kv~ and .py~ that are exposing the whole project source code.* But i should mention the gratitude and the respect i have for the Kivy project and the Kivy team. Their efforts allowed me to build and publish a nice Android application with Python that i am really proud of. Thank you so much Kivy team.
false
21,252,729
0.099668
0
0
1
Those files may be editor backups which kivy doesn't recognize. You can edit the build.py and add some patterns to BLACKLIST_PATTERNS. For your issue, you should add '*~' to the black list.
0
1,365
0
3
2014-01-21T08:24:00.000
android,python,kivy
How to hide python code file and other related files in a kivy project
0
2
2
21,253,288
1
0
0
While doing a breaf research on IronPython I got confused about it's execution model and how it integrates with C#. Can you please point, which of these assumptions are wrong: IronPython is Not compiled Ahead of time ( into a clr exe|dll with IL code) IronPython is distributed as script When executed, IronPython files are compiled at runtime into IL and then executed in a CLR AppDomain. Thanks
true
21,275,131
1.2
1
0
3
You can use pyc.py to create an exe/dll, but it's not well documented. Otherwise, you're basically right.
1
185
0
3
2014-01-22T05:45:00.000
python,clr,ironpython
IronPython and Ahead-of-Time Compilation
0
1
1
21,284,660
1
0
0
Can anyone give me a point in the right direction please? I've created a piece of Python code that creates a GUI. One button opens a 'new window', but if I click on the same button again I get another 'new window', keep clicking and I've got multiple copies of the 'new window'. I want the original window to be unaccessible whilst the 'new window' is open, and then accessible again when I close the 'new window'. Thanks in advance for any pointers.
true
21,338,613
1.2
0
0
2
You want to call grab_set() on your new window, which will prevent any events from going to the other window. When you're done, call grad_release()
0
154
0
0
2014-01-24T17:20:00.000
python,user-interface,tkinter,window
Python - GUI creates new window, but the original window is still usable. How do I stop this
0
1
1
21,338,743
1
0
0
Is there a general way for zooming in/out on a wx.Panel (all its content should be zoomed as well) ? Is it possible to define a new sizer type that would provide this feature ?
true
21,369,120
1.2
0
0
1
No. The wx.Panel does not support this feature out of the box. The FloatCanvas widget does support panning and zooming though. You could use that widget instead. Of course, I think you will have to draw the items on it instead of using regular widgets.
0
413
0
0
2014-01-26T20:59:00.000
python,wxpython
Zoom in/out on a wx.Panel
0
1
1
21,383,591
1
0
0
I've created a dynamic property in the Designer interface. How do I access this property in my code? I don't see any properties listed with the name I've provided. I've found a dynamicPropertyNames property that contains a QByteArray object and the name I provided, but I cannot figure out how to access the data I stored (nor do I know if this is even the correct place to be querying). Thanks!
false
21,395,056
0
0
0
0
Just because I had a similar problem and the reason wasn't a wrong object: The property's content can be accessed with toString().
0
1,777
0
3
2014-01-28T01:12:00.000
python,pyqt,qt-designer
How do I access a dynamic property in PyQt?
0
1
2
28,092,434
1
0
0
I need to display a chart that can be very large, for example the image resolution could be 100 000 x 1000. However, it seems like I am limited to 32768 x 32768 by the QImage. I can't reasonably redraw directly the chart at every paintEvent so I need to store it into a QImage (it could be a QPixmap that won't change anything). But then, it doesn't fit. My first idea was: Create a list of QImage Plot on the various QImage Redraw using the good QImages. The first and last points have been done quite easily. But the second point is more complex. I'm quite confident that my approach would work but it requires to overload the basic paint methods (draw rectangle, circles, etc.) in order to be able to paint on multiple images. So, before going any further, I would like to know what could be the other options.
false
21,462,118
0.066568
0
0
1
You can use the Qt Graphics View Framework. Create a QGraphicsView and a QGraphicsScene for it. Add items using QGraphicsScene::addPixmap (that returns QGraphicsPixmapItem which is derived from QGraphicsItem) and adjust their positions using QGraphicsItem::setPos. QGraphicsView will effectively draw your scene and handle scrolling and zooming if necessary.
0
622
0
1
2014-01-30T16:33:00.000
python,c++,qt
Draw an image too big to fit into a QImage
0
3
3
21,467,816
1
0
0
I need to display a chart that can be very large, for example the image resolution could be 100 000 x 1000. However, it seems like I am limited to 32768 x 32768 by the QImage. I can't reasonably redraw directly the chart at every paintEvent so I need to store it into a QImage (it could be a QPixmap that won't change anything). But then, it doesn't fit. My first idea was: Create a list of QImage Plot on the various QImage Redraw using the good QImages. The first and last points have been done quite easily. But the second point is more complex. I'm quite confident that my approach would work but it requires to overload the basic paint methods (draw rectangle, circles, etc.) in order to be able to paint on multiple images. So, before going any further, I would like to know what could be the other options.
false
21,462,118
0.132549
0
0
2
You probably do not want to display more than one QImage of data at a time. Few screens are more than 32k pixels wide or tall. So you want an abstract type that produces QImages on request for reading, at offsets and possibly at different zoom factors. The next problem is modifying this abstract type. An easy to use, not maximally performance version consists of letting users blit QImages into your internal storage (whatever that is). The user still has to "tile" their efforts, but can tile their efforts in ways that is convenient for them. A higher performance version exposes some of the underlying implementation, which we have not yet mentioned. A traditional implementation for large images is a tiled image. You have a grid of image tiles that abut each other. When someone asks for a blit from your image, you produce a temporary QImage, and blit the appropriate tiles onto it. And when someone blits to you, you figure out what the appropriate tiles are, and write parts of that source QImage over parts of them. The higher performance interface exposes these tiles. A low level interface lets the outside know where your tiles are, and lets them ask for them. This is a poor interface. A better interface exposes a sub tile iterator. They ask for a region, and you return a pair of iterators that describe the region. The data in the iterators consists of either a tile and a region in that tile as well as the location this region is in the "full image", or a sub-tile object (with linestride, line length, etc) and the location of the sub-tile object. Another good interface is a foreach style interface. Again, the user of the big image class passes in a region they want to work with, but a callback as well. That callback something similar to either one of the above results of the iterator dereference. This approach has two large advantages over the iterator approach. First, you can implement parallel image processing algorithms within your large image class. Second, it is much easier to write than rolling your own iterator. Once you have either of these, drawing is relatively easy. Determine the region you are drawing on (be generous). Iterate over the resulting tiles. On each tile, draw after applying the offset of the tile to the drawing.
0
622
0
1
2014-01-30T16:33:00.000
python,c++,qt
Draw an image too big to fit into a QImage
0
3
3
21,462,850
1
0
0
I need to display a chart that can be very large, for example the image resolution could be 100 000 x 1000. However, it seems like I am limited to 32768 x 32768 by the QImage. I can't reasonably redraw directly the chart at every paintEvent so I need to store it into a QImage (it could be a QPixmap that won't change anything). But then, it doesn't fit. My first idea was: Create a list of QImage Plot on the various QImage Redraw using the good QImages. The first and last points have been done quite easily. But the second point is more complex. I'm quite confident that my approach would work but it requires to overload the basic paint methods (draw rectangle, circles, etc.) in order to be able to paint on multiple images. So, before going any further, I would like to know what could be the other options.
false
21,462,118
0
0
0
0
You do realize that a 100,000 x 1000 RGBA QImage is 400MBytes? There's no point in wasting all that memory. Really, none. Just paint it every time, one request, in the paintEvent. Be clever about it so that you only paint what needs to be shown. I'd think one should focus on optimizing the painting process and your data structures so that it can be painted effectively. At small scales (zoomed out), a lot can be gained by approximating/decimating/interpolating the data so that it looks the same, but you don't waste time painting the same pixel too many times.
0
622
0
1
2014-01-30T16:33:00.000
python,c++,qt
Draw an image too big to fit into a QImage
0
3
3
21,469,131
1
0
0
I was using Python to process some data (int array). It is very slow. So I put the processing function in a c++ DLL and talk with it through ctypes. The data are loaded from swig-wrapped modules (c++). I browsed almost everywhere but found nothing to convert swig object of type 'int *' pointer to ctypes int pointer. How can I do it? Thanks
false
21,471,470
0
0
0
0
It seems no solution to do that after a few attempts. A simple way to fix this problem is wrapping the c++ code with SWIG, so can pass it to other SWIG-wrapped modules.
0
640
0
0
2014-01-31T02:31:00.000
python,c++
How to convert swig object of type 'int *' to ctypes int*
0
1
1
21,518,936
1
0
0
I am using Tkinter to create an application which requires a 0-9 numerical keypad to be built in to the UI. I plan to do this with 10 button widgets which enter the relevant number(s) into the currently selected Entry widget. I do not want to use one of the pre-made on-screen keyboards (e.g. Matchbox-keyboard) that are available, it needs to be bespoke to the application. So essentially - how do I simulate key-press events using on-screen buttons to enter values into entry fields without taking the focus off the entry field?
true
21,509,623
1.2
0
0
0
You don't need to simulate keypresses if all you want to do is insert the numbers into the entry widget. Just have the buttons directly insert their value into the entry widget with the entry widget insert method.
0
1,024
0
0
2014-02-02T10:46:00.000
python,tkinter,raspberry-pi,on-screen-keyboard
In Python (on Raspberry Pi) how do I create an embedded keypad within my Tkinter window
0
1
1
21,511,280
1
0
0
I have a PyQt program that's apart of package which is only about 9MB. This isn't much of a concern except that the Qt dependencies that get drawn in with it combined are closer to 100MB. So my question is there any logical and safe way of including only portions of the Qt library that I could include in my package and then no longer include Qt as a dependency, or a smaller alternative to the enormous Qt library that would still be compatible with my code?
true
21,514,717
1.2
0
0
0
I can't think of a way of doing what you want, but if you are using a standard PyQt distro, standard practice is to leave it up to the user to download and install dependencies. This could be automated by having an install script part of your ISO, that determines if pyqt is needed and if not available fetches the pyqt from your site and installs it, or automatically downloads source from riverbank site and attempts to build automatically.
1
223
0
2
2014-02-02T18:50:00.000
linux,qt,pyqt,size,python-2.x
Including only minimal Qt library with a program
0
1
1
21,546,276
1
0
0
I'm interested in creating my own programming language and I would like to use python. My question is, would a language written in Python using the PLY library be considerably slower than CPython or would they be about the same in terms of program execution speed? Also in terms of performance how much better would it be if I implemented it in C? Thanks, Francis
true
21,540,126
1.2
1
0
2
If you are implementing a compiler in PLY, the compilation may take longer - but that's irrelevant the execution speed of your program. For example, you could use PLY to write a C compiler. The compiler may or may not be faster than your other C compiler, but the resulting executable should run at a similar speed (unless you miss a lot of optimisations etc.)
1
243
0
0
2014-02-03T23:39:00.000
python,c,programming-languages,yacc,ply
Would a language written in Python using PLY be slow?
0
1
1
21,540,275
1
0
0
I would like to draw as many as 86,000 (small circles) on a Tkinter Canvas. On average it will be more like 8,600 circles. At times as few as 400. All of the circles being drawn at once are the same (size , color). The radius of the circles is related to the number of circles being drawn (as little as 1-2px when there are many circles to draw), but a difference in radius has had little overall impact. canvas.create_oval(px+r,py+r,px-r,py-r,fill='green') is quite expensive in computing time. Ideally I would pre-create the circle and paste copies of it on the canvas as needed. At the moment calling canvas.create_oval(...) 86,000 times takes almost 20 seconds. (The logic that decides what circle to draw where itself runs in less than 100 msec.) How would I go about copying a single circle instead of creating them all individually?
true
21,556,454
1.2
0
0
1
I don't think there's anything you can do to speed up the creation of circles. The canvas wasn't designed to handle 80,000 objects, and it doesn't support the ability to copy and paste items (beyond simply creating new objects with the same coordinates). It handles a few thousand OK, and even 10,000 is pretty performant on my machine, but 86,000 items is a lot. You might try creating a single image of the given size (or have pre-computed images). You can have a single PhotoImage instance that you use to create all of the images on the canvas. On my machine I can create 100,000 image objects on a canvas in just a couple of seconds. deleting that many objects, however, is still quite slow.
0
165
0
1
2014-02-04T15:25:00.000
python,tkinter,tkinter-canvas
Making logs of circles quickly with Tkinter
0
1
1
21,558,520
1
0
0
if I am not wrong wxMenuITem does not support tooltips is there an easy turn around to show a popup tooltip of help upon mouse focus on a menu item for a sec or 2 ?
false
21,613,027
0.197375
0
0
1
You need to realize that wxPython wraps the native widgets of the OS that it is running on, so if that underlying widget does not support the desired behavior, then wxPython will not either. It should be noted, however, that you would normally update the StatusBar with information about the menu items. That is how the wxPython demo for the menus works. In said demo, there is a binding to wx.EVT_MENU_HIGHLIGHT_ALL that is used to update the StatusBar. You might be able to use that event to add a tooltip. Alternatively, you might want to check out FlatMenu, which is a pure Python implementation of the wx.Menus. As such, you can easily add new behavior compared with trying to update something that is a wrapped C++ widget.
0
225
0
1
2014-02-06T20:11:00.000
python-2.7,wxpython
how to set wxTooltip or tooltip like on wxMenuItem
0
1
1
21,630,518
1
0
0
I recently spent some time working out how to use a QDataStream with a QTreeWidget in PyQt. I never found specific examples for doing exactly this, and pyqt documentation for QDataStream seems to be pretty scarce in general. So I thought I'd post a question here as a breadcrumb trail in case someone else down the line needs a hint. I'll wait a bit in case someone would like to jump in and take a shot at it, and I'll post back in a bit with my own efforts. The question is: In PyQt, how can I use a QDataStream to save QTreeWidgetItems to a file as native QT objects, and then read the file back to restore the tree structure exactly as it was saved? Eric
false
21,653,108
0
0
0
0
The QTreeWidget is a red herring. What you are saving is a generic QAbstractItemModel (treeWidget->model()) - after all, a QTreeWidget is a view, and has a built-in model. Now, those model's items are simply QVariants, and those are simply Python types, but also fully supported by QDataStream::operator<<. All you need is to choose a tree traversal (depth-first, breadth-first, or something else), and dump the items and their depth in the tree to the stream. When you read the stream, that's sufficient information to reconstruct the tree.
0
2,494
0
4
2014-02-08T23:30:00.000
python,qt,python-2.7,pyqt,pyqt4
PyQt: Saving native QTreeWidgets using QDataStream
0
1
3
21,654,212
1
0
0
I want to make a text editor with autocompletion feature. What I need is somehow get the text which is selected by mouse (case #1) or just a word under cursor(case #2) to compare it against a list of word I want to be proposed for autocompletion. By get I mean return as a a string value. Can it be done with tkinter at all? I'm not familiar with qt but I'll try to use it if the feature can be achieved with it.
false
21,675,320
-0.197375
0
0
-2
You can use QTextEdit::cursorForPosition to get a cursor for mouse position. After that you can call QTextCursor::select with QTextCursor::WordUnderCursor to select the word and QTextCursor::selectedText to get the word.
0
1,225
0
3
2014-02-10T10:59:00.000
python,qt,autocomplete,tkinter
How do I return word under cursor in tkinter?
0
1
2
21,675,660
1
0
0
I am new to Qt and developing with python. Would a python application developed using Qt framework and PyQt require the entire Qt framework to be installed on a user's machine in order to run a "exe" version of the application created with something like p2exe? Or would py2exe copy the required Qt framework components into the application that it creates?
true
21,699,483
1.2
0
0
-1
No need for further install. e.g. Py2exe will copy everything needed. If you have some special requirement you may have to copy other stuff manually. In my application I copy some extra ddls, some ico files and some matplotlib files.
1
477
0
1
2014-02-11T10:39:00.000
python,qt,pyqt
Do Frozen PyQt applications need the Qt to be installed on client machines
0
2
3
21,699,872
1
0
0
I am new to Qt and developing with python. Would a python application developed using Qt framework and PyQt require the entire Qt framework to be installed on a user's machine in order to run a "exe" version of the application created with something like p2exe? Or would py2exe copy the required Qt framework components into the application that it creates?
false
21,699,483
0.066568
0
0
1
I don't know what you mean by "frozen" but if your question is whether you can create an "exe" for a pyqt python script without installing python and pyqt on user machine then answer is yes. As with any other exe you don't need to install anything on user machine. I have created a few application using pyqt and converted them to exe using pyinstaller-2.0 and it works fine on any machine. Same is true with py2exe.
1
477
0
1
2014-02-11T10:39:00.000
python,qt,pyqt
Do Frozen PyQt applications need the Qt to be installed on client machines
0
2
3
21,699,917
1
0
0
I have a Twisted application that someone else wrote. There is a file run.py which makes it run in the foreground. There is also a twistd plugin named as service.tac that makes it run in the background. Around 90% of the code is the same in both the .py and .tac file. Is it possible to combine the two together? Or is that a bad idea?
true
21,708,441
1.2
0
0
4
You can run the tac file in the foreground: twistd -n -y service.tac. So perhaps you can just delete the run.py file.
0
441
0
3
2014-02-11T17:11:00.000
python,twisted
Right approach for running a Twisted application in the foreground or background
0
1
1
21,709,158
1
0
0
I am using windows 8 (not yet updated to 8.1) The code I am using is import ctypes SPI_SETDESKWALLPAPER = 20 ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "word.jpg", 0) print "hi" For some reason regardless if i give it a valid image (in the same directory as program) or not, regardless of type of image (bmp, gif, jpg) the code always ends up setting my background to a black screen. Why is this? How can it be fixed?
false
21,718,701
0.197375
0
0
2
Try passing SPIF_SENDCHANGE (which is 2) as the last parameter. You might also need to bitwise-or it with SPIF_UPDATEINIFILE (which is 1).
1
1,203
0
1
2014-02-12T04:30:00.000
windows,python-2.7,ctypes
How to Change Windows background using Python 2.7.3
0
2
2
21,718,853
1
0
0
I am using windows 8 (not yet updated to 8.1) The code I am using is import ctypes SPI_SETDESKWALLPAPER = 20 ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "word.jpg", 0) print "hi" For some reason regardless if i give it a valid image (in the same directory as program) or not, regardless of type of image (bmp, gif, jpg) the code always ends up setting my background to a black screen. Why is this? How can it be fixed?
false
21,718,701
0
0
0
0
Sorry, I know this is late, but the problem is that you need to include the path. Instead of "image.jpg" do r"C:\path to file\image.jpg" Otherwise python doesn't know where to look for the image.
1
1,203
0
1
2014-02-12T04:30:00.000
windows,python-2.7,ctypes
How to Change Windows background using Python 2.7.3
0
2
2
26,006,082
1
0
0
I am trying to integrate a complex python application (with a custom python interpreter shipped along) for OSX. In order to handle a set of issues due to cross platform requirements, I created a .app bundle pointing at a shell script with its CFExecutable entry in Info.plist. This works, and the invoked shell script starts up the actual application binary. However, I have the following problems: The .app icon bounces endlessly on the dock, never reaching the "activated" status. I guess it's because the shell script does not terminate. This dock entry has the correct "application icon" When the binary executable is invoked by the script, a new Dock entry appears with a generic python icon. This icon successfully starts up and stops bouncing as the application starts up. When I try to kill the first Dock entry via Force quit, the actual application still keeps running, as it's clearly controlled by the second entry on the dock. Is there a way to have this setup behave more naturally? Do I need to ditch shell script for an objective C wrapper? If I have to use a obj-C wrapper (instead of a shell script) to spawn my application, how can I prevent the same spawning of a secondary icon to happen? Edit: note, I am not running a python script. I am running a custom made python interpreter. py2app is not what I need.
false
21,755,235
0
0
0
0
I solved the problem, and in hindsight it was rather trivial. In the shell script, I need to invoke my binary with exec, so that the running bash process is replaced (a la execve()) rather than spawning a new process. The only problem is that my interpreter now replaces the icon with the stock one, but I have only one icon in the dock now, and behaves naturally.
0
138
1
0
2014-02-13T13:11:00.000
python,macos,bundle,.app
How to have a natural MacOSX .app of a complex python application (including custom interpreter) via a shell initialization script?
0
1
2
21,756,168
1
0
0
I am new to python programming and development. After much self study through online tutorials I have been able to make a GUI with wxpython. This GUI interacts with a access database in my computer to load list of teams and employees into the comboboxes. Now my first question is while converting the whole program into a windows exe file can I also include the .accdb file with it...as in I only need to send the exe file to the users and not the database..if yes how. My second question is... I actually tried converting the program into exe using the py2exe (excluding the database...am not sure how to do that) and I got the .exe file of my program into the "Dist" folder. But when I double click it to run it a black screen (cmd) appears for less than a second and disappears. Please help me understand the above issue and resolve it. am not sure if I have a option of attaching files...then I could have attached my wxpython program for reference. Thanks in advance. Regards, Premanshu
true
21,788,522
1.2
0
0
0
The console could possibly appear if you used the 'console' parameter to setup(). Switch to 'windows' instead if that is the case. Can't say for sure without seeing your setup.py script. Possibly your app could also be opening console, but again hard to say without seeing source. One thing to check is to make sure you are not printing anything to stdout or stderr. You might want to redirect all of stdout and stderr to your log just in case, and do this right at the top of your start script so that if some 3rd party import was writing to stdout you'd be able to capture that. The db is not part of your executable, so py2exe will not do anything with it. However, you should probably package your application with an installer, and you can make the installer include the db and install it along with the executable.
0
373
0
0
2014-02-14T20:01:00.000
python,user-interface
wxpython GUI program to exe using py2exe
0
1
1
21,789,391
1
0
0
I'm trying to write a program in either python or C++ using opengl that will allow me to control different displays. Currently I have three different displays, I have the computer monitor, a LCD and a DLP all hooked up to my computer. I want to control each screen separately, and I want to full screen them all so they go black. Currently when I try to use glutfullscreen() in only makes the computer monitor black, and I can't control the other two screen. In my set up I have removed the backlight from a LCD screen and I'm projecting onto it with a DLP projector to increase my dynamic range. I'm trying to write software to align the two image. I have it all working in MATLAB with mgl. But I don't know where to go with C++. I need to be able to control the pixels of where each image is displayed, but I can't access the other two screen.
true
21,790,472
1.2
0
0
2
Use something like SDL2 or GLFW3 for multimonitor support. They'll let you query the number of monitors and their sizes, as well as let you create multiple windows to cover them.
0
100
0
2
2014-02-14T22:14:00.000
python,c++,opengl,glut,pyopengl
Using different displays opengl
0
1
1
21,790,746
1
0
0
I just recently learned Python and Pygame library. I noticed that the rendering and main loop is automatically paused when I click and hold on the window menu bar (the bar with the title/icon). For example, in a snake game, the snake will be moving every frame. When I click and hold (or drag) the window menu, the snake is not moving anymore and the game is "paused". When I release it, it resumes. Is there a way to let the game NOT pause when I drag the windows menu bar?
false
21,895,657
0
0
0
0
This one is pretty easy, its seems you forgot to add a event callback. state 1 while (sate != 0): for event in pygame.event.get():
0
430
0
5
2014-02-20T00:30:00.000
python,pygame
Pygame built-in automatic pause?
0
1
2
21,896,365
1
0
0
I have a QLineEdit, and I need to know if there is a signal which can track mouse hover over that QLineEdit, and once mouse is over that QLineEdit it emits a signal. I have seen the documents, and found we have the following signals: cursorPositionChanged ( int old, int new ) editingFinished () returnPressed () selectionChanged () textChanged ( const QString & text ) textEdited ( const QString & text ) However, none of this is exactly for hover-over. Can you suggest if this can be done by any other way in PyQt4?
false
21,899,681
0.099668
0
0
1
You can use enterEvent, leaveEvent, enterEvent is triggered when mouse enters the widget and leave event is triggered when the mouse leaves the widget. These events are in the QWidget class, QLineEdit inherits QWidget, so you can use these events in QLineEdit. I you don't see these events in QLineEdit's documentation, click on the link List of all members, including inherited members at the top of the page.
0
1,894
0
2
2014-02-20T06:14:00.000
python-2.7,pyqt4,mouseover,qlineedit
QLineEdit hover-over Signal - when mouse is over the QlineEdit
0
1
2
21,900,144
1
0
0
I'm embedding Python in an Objective C application using PyObjC, setting the Python environment up by hand on the ObjC side (i.e. not using py2app). I'm starting the Python in a separate thread (on the ObjC side) with a call to PyRun_File(), and then one to PyObject_CallFunction() to start it doing something (specifically update some menus, register and handle menu callbacks). The Python function starts the run loop for the secondary thread and the callback class instance hangs around. All of this works. I can pass basic data such as strings to the initial Python function without problem and menu actions work as I'd like. I'd like to provide a pre-instantiated delegate instance to the Python function for ease of configuration (from the point of view of the Objective C developer). How do I pass an Objective C instance (my delegate) to the Python function? Is it possible? Are there bridge functions I'm missing? Do I need to create a suitably configured PyObject by hand? What sort of conversion should I do on the Python side to ensure the delegate.methods() are usable from Python and proxying works as it should? Are there any memory-management issues I should be aware of (on either side of the bridge)? I'm using Python 2.7, PyObjC 2.5 and targeting OSX 10.6. Happy to consider changing any of those if the solution specifically demands it. TIA.
true
21,988,970
1.2
0
0
3
The easiest way to ensure problem free usage of the bridge is to ensure that the delegate methods that you use don't use C arrays as arguments or return values and don't use variadic signatures ("..."). Futhermore ensure that all pass-by-reference arguments (such as the commonly used "NSError**" argument) are marked up with "in", "out" or "inout" to indicate in which direction values are passed. This ensures that the bridge can get all information it needs from the Objective-C runtime. There are two options to pass a preconstructed object to Python code: Create a class method that returns the object Use the PyObjC API to create the python proxy for the Objective-C object. The latter uses an internal PyObjC API (also used by the framework wrappers) and could break in future versions of PyObjC. That said, I don't have active plans to break the solution I describe here. First ensure that the right version of "pyobjc-api.h" and "pyobjc-compat.h" are available for the Objective-C compiler. Use #include "pyobjc-api.h" to make the API available. Call "PyObjC_ImportAPI" after initialising the Python interpreter, but before you use any other PyObjC function. Use "pyValue = PyObjC_IdToPython(objcValue)" to create a Python representation for an Objective-C object.
1
853
0
1
2014-02-24T13:18:00.000
python,pyobjc
How do I pass an Objective C instance into a PyObjC Python function when using PyRun_File()/PyObject_CallFunction()?
0
1
2
22,010,598
1
0
0
I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?
false
22,057,077
-0.066568
0
0
-1
Have you tried using pip-2.6 install package?
1
417
0
1
2014-02-27T01:15:00.000
python,linux,tkinter,tk,python-2.6
Installed Python from source and cannot import Tkinter - how to install?
0
3
3
22,057,396
1
0
0
I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?
true
22,057,077
1.2
0
0
1
I solved this by adding '/usr/lib/x86_64-linux-gnu' to lib_dirs in setup.py, then rebuilding python
1
417
0
1
2014-02-27T01:15:00.000
python,linux,tkinter,tk,python-2.6
Installed Python from source and cannot import Tkinter - how to install?
0
3
3
22,058,494
1
0
0
I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?
false
22,057,077
0.066568
0
0
1
Install the TCL and Tk development files and rebuild Python.
1
417
0
1
2014-02-27T01:15:00.000
python,linux,tkinter,tk,python-2.6
Installed Python from source and cannot import Tkinter - how to install?
0
3
3
22,057,115
1
0
0
I am using PySide in a not-so-MVC fashion, meaning, I try as much as possible not to edit the generated .ui to .py file, I put my application logic in packages (models) and I have one module (.pyw file) more like a controller for them all to initialize and perform management. Not too best of practice but I'm doing fine, all I want is I dont want to add code to the generated ui .py file (more like my view) Now here is the problem I Noticed that the generated PySide file doesn't inherit from the QDialog or QMainWindow as you have to create it when you are instantiating the class, as a result, events like closeEvent(self, event) doesn't work inside the class even when you put it there. I know hoe to write functions for QActions and widget connections, but I DONT KNOW HOW TO ADD A CLASS BASED FUNCTION TO A GENERATED PYSIDE CLASS OUTSIDE THE CLASS. If I have to edit the generated view class, I can perfectly tweak it to what I want BUT i dont want to because I can make amendment in QtDesigner and compile at any time This is my question, since I dont want to how do i attach say a closeEvent to the object created from the class in my controller class without touching the generated view class. Thanks
false
22,071,291
0
0
0
0
Monkey Patching did the job, I dont know why I didn't taught of that
0
1,710
0
0
2014-02-27T14:22:00.000
python,events,pyqt,pyside,qt-designer
Adding Event functions outside PyQt/PySide Generated Code
0
1
2
22,102,393
1
0
0
I can change color of all text in label, but I want to change color of one letter. Is that possible? I use tkiner and python 3.3.
false
22,071,505
0
0
0
0
No, it is not possible to change the color of one letter in a label. However, you can use a text widget instead of a label to color just a single character. You could also use a canvas widget.
1
820
0
0
2014-02-27T14:30:00.000
python,python-3.x,colors,tkinter,label
Change color of one letter in label. Python
0
1
1
22,078,545
1
0
0
I would like to read a HTML and I show it on a Tkinter window. I would like to know if this is possible with any module and if it's how can I do it, as I'm totally lost finding solutions. Thanks in advance.
true
22,077,846
1.2
0
0
5
There is no support for viewing rendered HTML in a tkinter widget. There was a project (tkhtml) to build a modern web browser using tcl/tk (which is what powers tkinter), but the project never got past a very early alpha release and the last check-in was in 2009.
0
3,286
0
3
2014-02-27T18:57:00.000
python,html,tkinter
Read a HTML file and show it on a Tkinter window
0
1
1
22,094,453
1
0
0
I'm trying to build the libpython33.a file so I can create my own C extensions using MinGW. For that, I need the python33.dll file to create a .def file and then convert that to the finally libpython33.a. In my Python 2.7 installation, I can see the file called python27.dll along with python.exe and pythonw.exe. But in the Python 3 folder I there's no DLLs. In the Python3/DLLs folder there's a file called python3.dll (not python33.dll). Is my Python instalation damaged or that's ok?
true
22,187,196
1.2
0
0
3
python33.dll is found under c:\windows\system32
1
5,326
0
2
2014-03-05T02:19:00.000
python,python-3.x,python-3.3
python33.dll not found in my Python installation path?
0
1
1
22,187,241
1
0
0
I have developed a pygtk application and i need to release it to customers. I am using python 2.7, pygtk 2.2 in ubuntu. My question is how can I bundle the required packages(python, pygtk, gobject) together with my application, so that even if these packages are not installed in client machine I can run my application. I tried with pyinstaller but, the executable depends on the glibc i.e executable created with higher glibc version will not work with the machine which has lower glibc version. So is there any way to create a release directory which includes all the packages required so that I can run my application in any system without installing the packages. Thanks in advance,
true
22,191,409
1.2
0
0
0
Just adding the solution to my own question! As suggested in the comments above installed packages by downloading the source and compiled them in a machine which had glibc2.5 then created binary executable of my pygtk app using pyinstaller I had tried compiling packages earlier also, but weren't checking the ./configure output properly. The problem was, I was trying to install gtk and pygtk without installing cairo and pango. So pygtk skipped building gtk packages because it did not find any cairo package. This was mentioned in the ./ configure script but I had not checked that. Summarizing: To configure pygtk to python need to folow these steps install sqlite-devel #If sqlite needed install python(2.7) install gtk(2.24.0) -> requires glib(2.27.3), atk(1.29.2), cairo(1.8.10), pango(1.22.4), gdk-pixbuf(2.21.3) install pygtk(2.24.0) -> requires pygobject-2.28.3, pycairo(1.8.10) All the above packages must be compiled to the same prefix, and need to set the PYTHON and PATHONPATH environment variables. The versions of packages also play major role. Added version in parenthesis that worked for me. There are many dependencies while installing some of the packages so I had to install following packages using yum: libxext, librender, gettext, zlib, libgtk2-devel
0
479
1
1
2014-03-05T07:34:00.000
python,linux,pygtk
Releasing pygtk application
0
1
1
22,983,513
1
0
0
I want to write a visualization for some complex scientific data in Python. I have done a similar thing a few years ago in Objective-C/Cocoa/OpenGL. The visualization will contain some fancy shader programs, so at least OpenGL 3.0 is required. Also, I need to draw a window and do some mouse/keyboard handling. Some GUI widgets would be nice, but not required. Python 3 support is highly desirable. I looked into: PyOpenGL, which has no window/mouse/keyboard handling. PyGlet, which only supports Python 2.7. PyQt, which only supports OpenGL 2.0. PySide, which is pretty much dead, and stuck in Qt 4.7. wxPython, which only supports Python 2.7. PyGame, which is pretty much dead. Do you know any library that can do modern OpenGL and some windowing in Python 3?
false
22,195,254
0.197375
0
0
1
My recommendation is PyOpenGL plus PyQt. Python plus either Pyglet or wxPython are possible alternatives. PyOpenGL (the Mike Fletcher version, right?) is the best Python OpenGL API I know of. It has support for OpenGL 3 and 4 and is just very nice and Pythonic. PyQt itself only supports OpenGL 2, but PyOpenGL will run inside a PyQt context. Since PyQt does have a Python 3 version, this combination should meet your needs. For the GUI stuff I prefer wxPython, but as you note that hasn't been updated for Python 3 yet. You could take a look at the wxPython Phoenix project, but that's very much a work in progress. Pyglet is also quite nice but has less GUI functionality that wxPython or PyQt. Think of it as the equivalent of GLUT. The Python 3 version is currently in alpha, but given that it's not a complete rewrite I'd expect it to be stable very soon. Hope this helps.
0
1,787
0
0
2014-03-05T10:37:00.000
python,opengl
OpenGL 3+ with Python 3
0
1
1
22,212,424
1
0
0
Basically I want to know the libraries which can do it, preferably in C or Python.
false
22,207,218
0
0
0
0
I can think of OpenCV, but it may be overkill, depending on what kind of "manipulation" you need. It is c/c++ lib, but also provides python and java wrappers.
0
34
0
0
2014-03-05T19:23:00.000
python,c,image,video
How to grab a frame from a video and then manipulate it and then reassemble the video with it?
0
1
1
22,207,404
1
0
0
I have a lot of images i need to load into a Pygame program. Can I load all these from a separate script which I load into my main program as a module and be used from within the main program? Any help much appreciated. Thanks in advance.
false
22,214,989
0
0
0
0
After considering both answers above what I simply did was write a script where I loaded all images and created a dictionary called image_dict with the image names as the keys and saved the program as "load_images.py" Then from the second program I did a "from load_images.py import image_dict". now the keys gave me the images. Thank you.
1
733
0
0
2014-03-06T04:31:00.000
python,pygame
Loading pygame images as a module
0
1
3
22,255,548
1
1
0
so I am actually trying to get into software development and I currently have just spent a few days making a GUI in Photoshop. Now I know how to code in Java and Python but I have never implemented a GUI before. I am stuck on this because I know I can write the code and everything but how do I take what I made in Photoshop add some java or python code to it to make certain things happen? I have zero experience in this and I have only written code to accomplish tasks without the need for a GUI.
false
22,215,361
0.197375
0
0
2
but how do I take what I made in Photoshop add some java or python code to it to make certain things happen No, you cannot expect things to happen magically, for that you need to learn front-end technologies like HTML, CSS, JavaScript etc and manually convert the UI which is in Photoshop to corresponding code. This applies for web applications. If you want to build desktop application, you need to use Swings, SWT etc to achieve the same. I have zero experience in this If this is the case, I recommend to read some basic tutorials, then you will get idea what to do
0
1,055
0
0
2014-03-06T04:57:00.000
java,python,user-interface,photoshop
UI Designed in Photoshop for Software
0
1
2
22,215,461
1
0
0
import sys sys.path.insert(1,"C:/Users/ravir_000/Desktop/python_CS105/python_CS105/Python27/Lib/site-packages") import math import random import pygame from pygame.locals import * pygame.init() How do you get rid of the error? Import error: Module use of python27.dll conflicts with this version of python. I was working on this a few hours ago and it was working fine. When I got into class it started giving me this error. I have tried to install/reinstall pyscripter and pygame but it still does not work. I am sure that my path to pygame is correct. Any ideas?
false
22,236,546
0.379949
0
0
2
You are trying to use a pygame distribution that is for python 2.7 with a different version of python. You should download and use the appropriate version. If installed correctly, there will be no need for sys.path.insert.
1
4,333
0
0
2014-03-06T21:36:00.000
python,pygame,importerror
Import error: Module use of python27.dll conflicts with this version of python
0
1
1
22,236,742
1
0
0
This .ui file is made by Qt Designer. It's just a simple UI. All the commands or codes for doing this on the websites I have looked through are not for windows.
false
22,266,802
1
0
0
16
In pyqt5 you can use: convert to none-executable python file : pyuic5 -o pyfilename.py design.ui convert to executable python file : pyuic5 -x -o pyfilename.py design.ui and also for resource diles(qrc): convert qrc to python file : pyrcc5 -o pyfilename.py res.qrc Note: that if you run the command in the wrong way,your ui file will be lost.So you have to make a copy of your files:)
0
110,222
0
22
2014-03-08T08:06:00.000
python,user-interface,pyqt,qt-designer
How to convert a .ui file to .py file
0
2
4
57,951,576
1
0
0
This .ui file is made by Qt Designer. It's just a simple UI. All the commands or codes for doing this on the websites I have looked through are not for windows.
false
22,266,802
1
0
0
15
To convert from .ui to .py in Windows Go to the directory where your ui file is. Press shift right-click your mouse. Click open command window here. This will open the cmd, check what is the directory of your (pyuic4.bat) file. Usually, it is in: C:\Python34\Lib\site-packages\PyQt4\pyuic4.bat. Write in the cmd: C:\Python34\Lib\site-packages\PyQt4\pyuic4.bat -x filename.ui -o filename.py (hit Enter) this will generate a new file .py for your .ui file and in the same directory Note: This command for Python 3.4 version and PyQt4 version. If you are using other versions you should change the numbers (e.g PyQt5)
0
110,222
0
22
2014-03-08T08:06:00.000
python,user-interface,pyqt,qt-designer
How to convert a .ui file to .py file
0
2
4
34,833,304
1
0
0
How can I make a childWindow access and/or modify an attribute from his MainWindow? I have a MainWindow that opens different childWindows, dependeing on the pressed button on the MainWindow. I would like any of the childWindows to be able to modify some attributes of the MainWindow, but I cannot get the good way to access them.
false
22,294,229
0
0
0
0
You could pass a reference (self) to your childwindow.
0
82
0
1
2014-03-10T07:21:00.000
python,qt,parent-child,mainwindow
attributes of Mainwindow from childWindow
0
1
2
30,509,870
1
0
0
I am using PyQt4 and Qt Designer. I have a QListWidget in which I populate after loading a file in my program. I want to set it so that all items will be checkable, as opposed to just selectable. I have found online that this is a 'flag' of the QListWidget, however, in Qt Designer I can't see where to do this. Is it possible?
false
22,340,514
0
0
0
0
The age-old question. There is an answer here, but I'll try to give some clarification: for several components there isn't enough to set item flag Qt::ItemIsUserCheckable, one needs to set item's check state for the checkbox to appear. Also, there is no widget flag to make all items checkable. An excerpt from Qt documentation: Note that checkable items need to be given both a suitable set of flags and an initial state, indicating whether the item is checked or not. This is handled automatically for model/view components, but needs to be explicitly set for instances of QListWidgetItem, QTableWidgetItem, and QTreeWidgetItem.
0
14,967
0
5
2014-03-12T02:00:00.000
python,qt,pyqt,pyqt4,qt-designer
Qt Designer QListWidget checkbox
0
1
2
66,103,178
1
0
0
I've been working with Python and PyGame days ago, and i noticed that when i move the player in my game, it will blit over itself again and again while moving, leaving a tail, is there any way i can clean up all the old sprites that the player left while moving? I tried bliting the background again while moving to remove them, but that was frustrating in a point. Any Idea? Thanks
false
22,361,870
0.099668
0
0
1
Just call window.fill([0, 0, 0]) each time in your main loop. Where the window is your pygame.display.set_mode() main surface. If you have any questions, just comment below.
0
421
0
1
2014-03-12T19:27:00.000
python,pygame,pygame-surface
PyGame, How to clean up Old Sprites
0
1
2
22,363,605
1
0
0
I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source. I've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only the DLL file. Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like. Is SWIG the right route to use in this case? I am trying to load this DLL in Python so I can utilize a function. From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this. Boost.python seems to require changing the underlying C++ code to make it work with Python. To sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code?
false
22,378,590
0
1
0
0
To use a library (static or dynamic), you need headers and library file .a, .lib... Its true for c++ and I think its the same for Python
0
1,508
0
0
2014-03-13T12:25:00.000
python,c++,dll,swig
SWIG C++ Precompiled DLL
0
2
3
22,378,831
1
0
0
I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source. I've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only the DLL file. Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like. Is SWIG the right route to use in this case? I am trying to load this DLL in Python so I can utilize a function. From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this. Boost.python seems to require changing the underlying C++ code to make it work with Python. To sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code?
false
22,378,590
0
1
0
0
SWIG cannot be used without the header files. Your only option is a lib like ctypes. If you find ctypes doesn't do it for you and you can't find alternative then post a question with why ctypes not useable in your case.
0
1,508
0
0
2014-03-13T12:25:00.000
python,c++,dll,swig
SWIG C++ Precompiled DLL
0
2
3
22,389,172
1
0
0
Is there a way to allow wxTextEntryDialogs to accept the tab character? I'm using wxPython and would like to accept tabs so that I can ask the user for the delimiter used in a text file.
true
22,419,345
1.2
0
0
1
It is possible to paste it in, but this is obviously not user friendly. I'd use a custom dialog with the predefined choices (e.g. radio buttons) for TAB, comma, semicolon etc and a text control for a custom separator entry.
0
65
0
0
2014-03-15T03:59:00.000
python,wxpython,wxwidgets
wxTextEntryDialog with Tabs
0
1
1
22,424,553
1
0
0
I have a really specific need : I want to create a python console with a Qt Widget, and to be able to have several independent interpreters. Now let me try to explain where are my problems and all tries I did, in order of the ones I'd most like to make working to those I can use by default The first point is that all functions in the Python C API (PyRun[...], PyEval[...] ...) need the GIL locked, that forbid any concurrent code interpretations from C ( or I'd be really glad to be wrong !!! :D ) Therefore, I tried another approach than the "usual way" : I made a loop in python that call read() on my special file and eval the result. This function (implemented as a built extension) blocks until there is data to read. (Actually, it's currently a while in C code rather than a pthread based condition) Then, with PyRun_simpleString(), I launch my loop in another thread. This is where the problem is : my read function, in addition to block the current thread (that is totally normal), it blocks the whole interpreter, and PyRun_simpleString() doesn't return... Finally I've this last idea which risks to be relatively slow : To have a dedicated thread in C++ which run the interpreter, and do every thing in python to manage input/output. This could be a loop which creates the jobs when there is a console needing to execute a command. Seems not to be really hard to do, but I prefer ask you : is there a way to make the above possibilities to work, or is there another way I didn't think about or is my last idea the best ?
false
22,435,352
0
0
0
0
If your main requirement is to have several interpreters independent from each other, you'd probably better suited doing fork() and exec() than doing multithreading. This way each of the interpreters would live in it's own address space not disturbing one of the others.
1
1,118
0
2
2014-03-16T09:50:00.000
python,c,multithreading,gil
Python & C/C++ multithreading : run several threads executing python in the background of C
0
1
2
22,435,597
1
0
0
I'm writing a prototype for the tactical spaceship combat in a game I'm working on. The basic idea of the part I'm working on right now is that a 'ship' object (which represents a single individual ship) contains a list of 'system' objects. When a ship is first initialized, it calls an initialize() function on each of its systems (which is not the same as the standard __init__ function called whenever an instance of an object is made) that will (among other things) call a register() function on the ship the system is a part of. That register() function takes a string as a parameter, which is the name of a function that the system expects to be called on the ship object. Whenever that function is called on the ship object, the ship object will call it on all systems that registered to receive it until either one of them returns True (indicating that the system 'dealt with' the action in a final manner) or it runs out of systems that have signed up to receive the call. So far so good. However, some systems might want to get their calls before other systems do. For example, your hull system will want to be the last system to receive a hit(); the shields will want to hear it first. The simplest solution might be to implement a priority system: the shields will call myship.register("hit",priority=1), and the hull will call myship.register("hit",priority=0). But now we imagine that there ought to be "super-shields" that intercept the hit before the main shields take it. Simple enough: give them priority 2. This might get annoying for the developer if a whole lot of systems want to take a certain request, but he can manage it. However, this game is intended to be highly user-extensible. If someone releases an addon that (for a stupid example) plays Full Metal Jacket sound clips every time the player's ship is hit, the developer of that addon might not be aware of the addon that adds the "super-shields", and give his Annoying Drill Sergeant system the same or lower priority as the super-shields, and thus may not receive hit messages before they are acknowledged by the super-shield. This is, of course, undesirable behavior. Does anyone have any ideas as to how to avoid this problem? Others have suggested having a way a system can request the priority level one higher than or one lower than the highest/lowest current priority level, but that causes largely undefined behavior, since the priority levels would be based on the order in which the systems are initialized. I've also considered adding a "super-priority", where a system always receives the message before other systems but cannot acknowledge and stop it. This would be only a partial solution though; it'd fix the given example, but not a situation where there are super-shields layered under super-super-shields that need to block the message.
false
22,438,569
0.197375
0
0
1
The issue is trying to give an absolute value to the priority. Rather you need to build a relative priority data structure for each call. This way you can say that hit() is highest priority for super-shields then shields then hull. The mod would then simply need to change the hit sound effects for the hull or add an additional sound effect to be played as well. The most straightforward way to go about it would requiring that any new object's priority for a given call be linked to another object with that call. It then requires selecting if the new object's priority is lower or higher. So shields and hull are linked (hull < shields) and super-shields and shields are linked (shields < super-shields). That information would make it fairly easy to build a 2D multiple items (2D to have allow for same priority) linked list that holds the priorities for each call. Thus the register function might look like this, "myship.register("hit",shields,"lower",super-shields)" and give shields a lower priority than super-shields. You could allow for additional conditions such as myship.register("hit",hull,"lower",shields,"lower",super-shields) if you already had the hull and super-shields, and wanted to add shields between them. However, then you run the risk of having to deal with contradictions or violating the conditions.
0
112
0
0
2014-03-16T15:06:00.000
algorithm,python-3.x,message-passing
Algorithm design for systems on a spaceship taking messages
0
1
1
22,452,071
1
0
0
Is there a way to use OpenGL to draw offscreen? What I want to do is this: I want to be able to use functions like glVertex, and get the result in a 2D pixel array. I am using Python. I tried using PyGame, but it's not working very well. The problem with PyGame is that uses a window event though i don't need it. In addition, I had to draw to scene + flip the screen twice in order to access screen pixels using glReadPixels. An other problem is that I can't have more that one window at once. Is there any proper way to accomplish what I am trying to do?
false
22,440,743
0.379949
0
0
2
What you are asking for seems to be two things in one... you want an off-screen buffer (FBO) and you want to get the contents of the framebuffer in client memory. Can you indicate which version of GL you are targeting? If you are targeting OpenGL 3.0+, then you can use FBOs (Framebuffer Objects) and PBOs (Pixel Buffer Objects) to do this efficiently. However, since you are using glVertex, I do not think you need to bother with efficiency. I would focus on learning to use Framebuffer Objects for the time being. If you are not using GL3 you might have access to the old EXT FBO extension, but if you do not have that even you might need a PBuffer. Note that PBuffers and Pixel Buffer Objects are two different things even though they sound the same. Before GL3/FBOs, WGL, GLX, etc. had special platform-specific functionality called Pixel Buffers for drawing off-screen.
0
587
0
0
2014-03-16T18:09:00.000
python,opengl,pygame,pixels
Draw with OpenGL offscreen
0
1
1
22,441,324
1
0
0
I'm wondering how I can change the font of a Python Tkinter label widget so that half the displayed text is bold and half is not without having to use two labels. The text for the widget is assigned prior to the label actually being created and stored in a variable so I need some kind of flag presumably to tell it how much of the string should be bold. I don't it is possible but suggestions appreciated.
false
22,453,554
0.291313
0
0
3
There is nothing you can do with the label widget -- it only supports a single font and single color for the entire label. However, you can easily substitute a canvas or text widget anywhere you need this feature. There's no reason why you can't use a text widget that is one line tall and a dozen or so characters wide.
0
9,774
0
2
2014-03-17T11:51:00.000
python,widget,tkinter,label,styling
How to change font style for part of a tkinter label
0
1
2
22,455,831
1
0
0
I'm developing some Python scripts to read/parse/process some .vrscene files. From others' examples, I can see that there is a Python SDK for VRay called vrayutils. I want to get this information from the SettingsOutput object. From a .vrscene file I want to get the total frame numbers. Does anyone know where I can get that Python library or how I can call it?
true
22,456,509
1.2
0
0
1
I was able to do some of the things by parsing the file using basic Python and then extracting the things I needed. The V-Ray API has a proprietary license, and there is no open source way to access the .vrscene I decided to try with a trial version of the SDK, and by using the SDK you will be able to find a nice Python build wrapped with a bunch of examples within the V-Ray Application SDK. The price is 1250 euro annually for a single development license (for one server node). Support is included. They can give you a preliminary evaluation version for 3 months under NDA (What I used). No reverse engineering is permitted so if you are planning to develop over V-Ray you should buy it.
0
1,560
0
0
2014-03-17T14:07:00.000
python,sdk,render,maya,autodesk
Getting access to VRay Python SDK
0
1
1
22,980,455
1
0
0
I'm using IPython qtconsole under windows 7, and when I first write a method name and type the bracket, a popup shows method parameters. What is the way to display that popup explicitly, once it has disappeared? This is pretty common 'show method parameters' shortcut that I'm talking about, but I've failed to find the shortcut to it after an embarrassing amount of google searches.
false
22,501,431
0
0
0
0
In Spyder, try View - Panes - Object inspector. Then type the full name of the function.
1
1,486
0
1
2014-03-19T09:32:00.000
python,ipython
How do I display function arguments in ipython qtconsole?
0
1
2
28,310,783
1
0
0
First, sorry for my language, english is not my native language :-/ I have some troubles using wxpython 2.8/python 2.7 with Windows. My app using wxPython is quite big now and uses a lot of widgets. My problem is : In a for loop, i open a frame as a variable (myVar = myFrame(...)), and give it some values/variables (like -> myVar.setval('xx', 42)) . Then, it will fill some textareas, grids, etc. from some requests in my database (from the child frame). At the end of the traitment, my child frame generate a pdf file, and print it, then it closes itself with the original self.Destroy() method, not surcharged, of wx.Frame. A lot of frames are created, one by one, with the same variable (myVar in the example). But, recently, I figured out some issues with more iterations in my loop than usual... With the same configuration (same data with a dump from database), it always crashes at the exact same moment (not on particular data), after a certain number of iteration in my loop. WxPython uses maximum amount of GDI allowed by Windows (error 1158). In fact my GDI resources from destroyed frames are not released! I read that there's a queue of destroyed objects, waiting to be really killed when no more events are waiting in wxPython and then they are not released because of constant work (the loop). On linux, there is not this issue, everything works fine (but I need it works on Windows). I tried wx.Yield method but nothing changed... I looked threads, but GUI widgets have to be used in wx main loop... If one of you guys has an idea, it will be wonderful ! [SOLVED] The solution i found is to call wx.Yield() to releases unused ressources. But this only work perfectly on linux. On windows, i need to call wx.Frame.DestroyChildren(). It seems to be OK for now :-)
false
22,511,472
0
0
0
0
OP seemed to find the solution. The solution I found is to call wx.Yield() to releases unused ressources. But this only work perfectly on linux. On windows, i need to call wx.Frame.DestroyChildren().
0
296
0
2
2014-03-19T15:57:00.000
python,windows,wxpython,gdi
wxPython : GDI ressources are not release after wxFrame.destroy()
0
1
1
23,710,926
1
0
0
I seen the some difference when I execute the .py file. I have observed two cases, 1) when I run the .py file using the python mypython.py I got the result. But .pyc file not created in my folder. 2) when I run the .py file using the python -c "import mypython" I got the same result. But .pyc file was created in my folder. My question is why first case not created .pyc file ?
true
22,552,304
1.2
0
0
0
Python saves the precompiled .pyc file only for imported modules, not for the main script you're running. Running a program as main or importing it as a module is not the exact same thing, but very similar because in a module everything that is at top level is executed at import time. Note that for main program the source code is completely parsed and compiled too (so for example if you have a syntax error in last line nothing will be executed). The difference is only that the result of compilation is not saved back to disk.
1
102
0
1
2014-03-21T07:03:00.000
python,compiler-construction,interpreter
Understanding python compile
0
1
2
22,552,400
1
0
0
I'm evaluating Kivy for android development. I need to know if is it possible to create an application with multiple windows using Kivy. I dont know for sure how android works with this kind of approach. In c#, windows forms, we have a main window and from that we open/close another forms. How can I accomplish this approach using Kivy for android ?
true
22,563,386
1.2
0
0
3
What do you mean by 'window'? In the practical sense, you can easily create different screens with kivy and switch between them, e.g. to have a menu screen, settings screen, game screen etc. Is this the kind of thing you mean? More generally, you can easily achieve any particular windowing behaviour you want within kivy. Android itself works with activities, a particular way of choosing what is displayed, how apps move between screens, and also how apps may call particular subsets of one another (plus a lot more of course). You don't need to know about this to use kivy, it works within a single activity (plus appropriate interaction with the rest of the system), but you should read up on it if you want to understand how android manages programs and how this is different to most desktop environments.
0
1,083
0
0
2014-03-21T15:49:00.000
android,python,kivy
Kivy Multiple windows
0
1
1
22,563,987
1
0
0
I am willing to make a Terminal like QTextEdit using pyqt4, but do not know what property to edit,so that when text from a process is dumped, it should start from the bottom and goes up. Any help for a starting point would be really appreciated. Cheers.
false
22,574,996
0.099668
0
0
1
I tried similar things before. For logging. Its a pain and it is very slow for a lot of lines. If you expect having a lot of lines cummulating in the terminal then consider writing an item model and attach it to a view. There are lot of possibilites in tweaking the appearance of such a view and it allows showing a small portion out of a big amount of data without becoming painfully slow. Also it allows to insert data at any position quickly.
0
541
0
0
2014-03-22T07:54:00.000
python,qt,terminal,pyqt,pyqt4
Loading text in QTextEdit from down up like in Terminal
0
1
2
22,578,889
1
0
0
What are the packages which need to be installed for writing scripts using PyJius in system ? Is there anyway by which i could run these python scripts on android phone ? What is K ivy Launcher for android ? Will it be helpful for executing my scripts ? How actually Kivy works ( in detail say in I want to switch on Bluetooth using scripts, which are the things in the K ivy architecture gets invoked by doing so ? ) What i need is to write scripts on computer and then after sending those scripts to my phone, then i need to execute my scripts from phone. Get the results on the phone and send those results to system.
false
22,578,624
0.664037
0
0
4
What are the packages which need to be installed for writing scripts using PyJius in system ? I'm not sure what you mean here. To run use pyjnius, all you need is...pyjnius. It is a separate module, not part of kivy itself, though kivy uses it on android. Kivy's mobile build tools automatically package this when you build an android apk. What is K ivy Launcher for android ? Will it be helpful for executing my scripts ? An app that can dynamically open kivy apps from your user data directory. You can use it to upload and run kivy scripts/apps on your device. It is most useful for quick tests, not as a way to distribute apps. For this, it's very easy to build your own apks, which gives a lot more flexibility in what you do and what you package. How actually Kivy works ( in detail say in I want to switch on Bluetooth using scripts, which are the things in the K ivy architecture gets invoked by doing so ? ) I'm not sure what you're asking here. Kivy is a graphical framework for python, using an optimised opengl interface...you write python gui applications with it. For things like bluetooth on android, you can use pyjnius (or more easily, wrapper projects like plyer providing an abstracted python api, though I don't think plyer has bluetooth quite yet). This generally isn't very hard, I've seen bluetooth done before. Kivy itself is a graphical framework, these other tools are sister projects but separate from the graphics. What i need is to write scripts on computer and then after sending those scripts to my phone, then i need to execute my scripts from phone. Get the results on the phone and send those results to system. You can certainly do this with kivy, by putting the scripts in an app that you run. Network communication also isn't hard - it's separate to kivy itself, but you have access to all the normal python modules you might use.
0
768
0
1
2014-03-22T14:07:00.000
android,python,kivy
Kivy for android
0
1
1
22,578,797
1
0
0
I finally have some idea how to build Kivy app in Xcode with help of Kivy-ios. But Xcode and mac environment is new to me. My issue is: how to compile other python modules that required for my application. There is 'build-all.sh' in 'kivy-ios/tools' that builds standard things, but how to add some other module. In particular, I need Requests module. Maybe there's some template script to include custom python modules? Thanks in advance
true
22,621,259
1.2
0
0
3
I don't know how kivy-ios manages different modules, but in the absence of anything else you can simply copy the requests module into your app dir so it's included along with everything else.
0
462
0
3
2014-03-24T21:46:00.000
python,ios,xcode,python-requests,kivy
Compile custom module for Kivy-ios
0
1
1
22,622,162
1
0
0
I'm trying to set a custom background for selected items in wxPython 2.8. I cannot figure out how to do so. I've tried SetItemBackground with no luck.
true
22,624,070
1.2
0
0
0
Selected items in wxListCtrl, wxListBox and so on always use the system background selection colour, it can't be changed.
0
209
0
0
2014-03-25T01:55:00.000
python,wxpython,wxwidgets
Setting selection background in ListCtrl
0
1
1
22,635,854
1
0
0
Should/does NDK9 work with android API19? (though it was released with API18). Full story: I was building an Android App using kivy, python-for-android and buildozer. compiling with MDK9 (ie 9d) and api19 result in error: E/AndroidRuntime( 1773): java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "wait4" referenced by "libpython2.7.so"... compiling with NDK9 (ie 9d) and API18 works. :)
false
22,624,987
0
0
0
0
Android SDK are released more often that NDK. It happened more than once that if you use a too recent SDK, the NDK will not have the .h for it. Now i'm not sure this would be related to your issue at all.
0
681
0
2
2014-03-25T03:35:00.000
android,python,android-ndk,kivy
android nkd and sdk compatibility issue (run time linker error)
0
1
2
22,644,004
1
0
0
I made a simple GUI (wxpython) application (some static text, buttons, comboboxes etc) and made exe file with pyinstaller, but the Avast antivirus says it's a virus. How can I fix this?
false
22,693,665
0
0
0
0
I have the same issue. If you are using Avast, do not uninstall it. This will make your computer vulnerable from threats. If you are sure, you can click 'add exclusion' when the Avast Hardened Mode blocked a program thing comes up. If this isn't correct, please comment or edit.
1
1,891
0
3
2014-03-27T16:30:00.000
python,pyinstaller,antivirus
python executables alarms antivirus
0
1
2
70,388,992
1
0
0
So I was wondering if there is any Python package that can allow a pure Python application with a graphic interface to be embedded in a website. I have an application with a Tkinter interface that I want to make available on a website. Any way to do this without converting too much code? Thanks!
false
22,741,838
0.066568
0
0
1
It's impossible. Python/Tkinter app is a desktop application, which requires desktop manager, has access to file system etc. Web application is a different stack of technologies (HTTP, HTML, javascript etc), it is not possible to mix them
0
74
0
0
2014-03-30T08:22:00.000
python
Web Server/Site Python
0
1
3
22,741,877
1
0
0
anyone know how to hide python GUI Tkinter, I 've created keylogger, for GUI I used python module Tkinter , I want to add button called HIDE, so when user click it it will hide GUI , and when user press key like CTRL+E , it should unhide GUI....?
false
22,764,927
0
0
0
0
To get rid of a GUI window I used the following in my code. window.destroy() and the following to bring it up again. nameoffunction() window.lift()
0
11,986
0
3
2014-03-31T14:55:00.000
python,tkinter
How To Hide Tkinter python Gui
0
1
4
46,719,809
1
0
0
I have created a small chat app using pyside. I want to add 'Emoticons'(smileys) options for users to chat. I haven't getting any material on internet. I will be really grateful if someone helps to solve this problem. Thanks in advance.
false
22,778,197
0.197375
0
0
1
Qt supports a thing called SVG font. It is a font where every letter is a colored vector image. You can use these in text fields and webkit.
0
114
0
0
2014-04-01T06:15:00.000
python,user-interface,pyqt,pyside
Adding Emoticons to app
0
1
1
22,778,301
1
0
0
I'm using some predefined accelerators connected with certain hot keys. Is it possible to temporarily disable them? I don't want to change the hot keys, in order not to confuse users. The accelerators are activated when typing into a combo box, which really is unacceptable.
false
22,782,726
0.099668
0
0
1
As far as I know you cannot disable them. They will receive any key stroke that is not consumed by the focused Window.
0
462
0
12
2014-04-01T10:09:00.000
python,gtk
How to disable accelerators when typing text in GTK+
0
1
2
37,508,137
1
0
0
I am pretty new to Python and I have been pretty annoyed with this problem. I am not sure if this matters, but I run my .py file with Python 2.7.6 with python installed on my computer, not using it on any online thing or other program. Every time I come across an error, my program works fine until it comes to the error, but the window disappears right before I can possibly read whatever the error said it was... Anyways, I haven't been able to find out what is wrong with my programming, and I am tired of guessing and guessing what is wrong. How can I extend the time so I can read the error message? Or something like that? Thanks
false
22,830,060
0.099668
0
0
1
You should run it from command window/terminal instead of double clicking on the file.
1
2,813
0
1
2014-04-03T06:57:00.000
python,syntax-error,runtime-error,message
Python - I can't see my what my error is because the window disappears immediately
0
1
2
22,830,091
1
0
0
Good Day All! I am trying to figure out how to limit the popup box shown bellow. I am not trying to trim the text, I am however trying to set the amount of characters in the popup per line. eg: 30 Characters per line in the popup box tkMessageBox.showinfo("Results", str(e)) Any suggestions, without modifying the text itself?
false
22,831,462
0
0
0
0
There is nothing you can do with the tkMessageBox. You either have to alter the text or create your own message window. The latter isn't very difficult -- a Toplevel, a Text widget with a scrollbar, and a couple of buttons is about all you need.
0
157
0
0
2014-04-03T08:07:00.000
python,popup,tkinter,size,line
Tkinter Limit Size Of Popup per line
0
1
2
22,835,256
1
0
0
I am a First Year Physics major at Goshen College. I am supposed to create a final project for my programming class. I am thinking about doing the game Battleship. I realize that I could find the complete code somewhere online but I would really like to write my own.I came up with a list of things I would like to try to implement into the game and a general idea of how I would like the program to run. Make four 10 x 10 grids. One with stored locations for the computer's ships, one with the player's ships, and two to be displayed, keeping track of both you and the computer's guesses. By using format (a,6), user/computer can guess location. Tells user what ship they are placing and how big it is. User gives a star cordinate, then gives either up, left, or right to decide which direction the ship lies. This is grid one. Grid two is a stored grid of ships. That will be the computer's grid. The game will keep track of your guesses, and put circles where you miss, x's where you hit and ~'s are water(spaces you haven't guessed. This is grid three. Grid four is the computer's guesses. Random computer guess until hit. Then use algorithm to check all adjacent spaces until the ship is sunk. Take turns Display Grids three and four simultaneously. I really just don't know where to start. I have a general idea of the logic that I would need to create the game, I just don't know where to jump in and start defining programs. Thanks!
false
22,837,709
0.197375
0
0
2
Your algorithm looks perfectly fine. As you aim for this to be implemented in Python, I'd start with creating simple PyGame (or other library of your choice) application, that only draws two of your grids. That will help you debug your other functionality, once you'll see it better than array dump in the console. Alternatively, you may implement everything text-mode based just for now, and later enhance it with graphics — making your application more like "query-response", printing two grids with plain print() and asking for move with raw_input() — that simple.
0
1,306
0
2
2014-04-03T12:24:00.000
python
Battleship in Python
0
1
2
22,837,881
1
0
0
I have to make a computer graphics project on "Vote for better Nation" using python in a week..I have a knowledge of pygame but don't know how to create a particular object(like small cartoon man)..And then how to make it move..So please help me if anyone knows how to make a moving object.. Sorry For The English Thank You
false
22,884,351
0
0
0
0
There is a series of books on Python Graphics called "Python Graphics for Games" (Amazon). It covers vector drawing and animation. Author Mike Ohlson de Fine.
0
1,621
0
0
2014-04-05T17:37:00.000
python,python-2.7,graphics,pygame,turtle-graphics
Computer Graphics with python
0
1
2
31,048,800
1
0
0
I am new to pygame and I am working on a distributed peer-peer multiplayer game. I tried doing the following but I was not able to figure out how. I have a player class and an enemy class. The player and enemies are all part of different sprite groups. Say in a 4 player game where there is one player object and 3 enemy objects, When a player fires , I use the spritecollide method to check collision with the enemy sprite group. But I want to identify in specific as to which enemy has been shot within the spritegroup. I am quite not able to figure that out. Is that even possible ?
false
22,897,317
0
0
0
0
Seeing as it sounds like enemy objects and player objects can do the same thing, maybe you should have one common class for both enemy and player. This could be called for example a creature class. Then based on if the creature is a enemy or player you can control it using an EnemyAI class or a UserInput class. As for identifying who was hit, you can easily add a name variable within each of the creature classes that you define upon declaring a new creature. Then when you evaluate hits, you can have the function return the name of the creature who was hit.
0
162
0
0
2014-04-06T17:19:00.000
python,pygame
Detecting sprite object within a sprite group on collision
0
1
1
22,897,426
1