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 a beginning programmer in Python and I have a strange problem with my computer. When I have a .py file on my computer (containing a script that works), and I double click on it to open, the following happens: the program opens (it's the black screen view), but it shuts itself down within a second, and the program isn't executed. However, when I right click and choose "edit with IDLE", everything works as normal.
I didn't have this problem from the beginning on, but then I installed some other versions of Python and I think that's the moment when scripts didn't want to open anymore. | false | 13,959,257 | 0.132549 | 0 | 0 | 2 | but it shuts itself down within a second, and the program isn't executed.
Yes, the program is being executed. It is being executed so quickly that you don't have a chance to see what is happening.
Put raw_input() at the end of your code so that the console window doesn't close instantly. | 1 | 218 | 0 | 1 | 2012-12-19T19:00:00.000 | python,windows | computer (windows XP) doesn't want to open .py | 0 | 2 | 3 | 13,959,312 | 1 |
0 | 0 | I'm a beginning programmer in Python and I have a strange problem with my computer. When I have a .py file on my computer (containing a script that works), and I double click on it to open, the following happens: the program opens (it's the black screen view), but it shuts itself down within a second, and the program isn't executed. However, when I right click and choose "edit with IDLE", everything works as normal.
I didn't have this problem from the beginning on, but then I installed some other versions of Python and I think that's the moment when scripts didn't want to open anymore. | false | 13,959,257 | 0.132549 | 0 | 0 | 2 | Austin is right, you made a console app, and once its finished(in microseconds), it closes itself.
Create a mainloop or use Austin's trick, to force app not to close itself. | 1 | 218 | 0 | 1 | 2012-12-19T19:00:00.000 | python,windows | computer (windows XP) doesn't want to open .py | 0 | 2 | 3 | 13,959,538 | 1 |
0 | 0 | I want to create a cross-platform application (Ubuntu and Android) with a notification icon. Is there a standard way to create such an app using Kivy? | true | 13,962,888 | 1.2 | 0 | 0 | 5 | Short answer, no… if you want to define such an API and implement it using platform-specific libs (libnotify on Ubuntu, and pyjnius on Android), that would be welcomed though. Others will help make it work on other platforms. | 0 | 641 | 0 | 5 | 2012-12-19T23:20:00.000 | android,python,linux,notifications,kivy | Kivy: crossplatform notification icon | 0 | 1 | 1 | 14,005,492 | 1 |
0 | 0 | I have my game running in a while True loop and I would like to be able to ask the user to "Play again?" I already have the code for a rect to pop up with the text but I need a way for the user to click on the rect or hit y for yes and the code run its self again. | false | 13,984,066 | 0.039979 | 0 | 0 | 1 | To tell if the user clicked on the rect, just set a 1 by 1 rect at the mouse position then when they click, check if the rects are colliding. Then, just call the loop again by having it be its own function, like DeadChex said. | 0 | 25,890 | 0 | 4 | 2012-12-21T03:58:00.000 | python,user-controls,while-loop,pygame | Pygame restart? | 0 | 2 | 5 | 14,188,676 | 1 |
0 | 0 | I have my game running in a while True loop and I would like to be able to ask the user to "Play again?" I already have the code for a rect to pop up with the text but I need a way for the user to click on the rect or hit y for yes and the code run its self again. | false | 13,984,066 | 0.07983 | 0 | 0 | 2 | Have the loop it's own method, call it from a main() run, when the game is over and ends, have main() ask the user if they want to play again, and if so recall the main loop after setting everything as its default
or
Just have the part that asks again clear and reinitialize all variables as there defaults and let the loop if the user wants to play again | 0 | 25,890 | 0 | 4 | 2012-12-21T03:58:00.000 | python,user-controls,while-loop,pygame | Pygame restart? | 0 | 2 | 5 | 13,984,092 | 1 |
1 | 0 | By default, the built-in views in PyQt can auto-refresh itself when its model has been updated. I wrote my own chart view, but I don't know how to do it, I have to manually update it for many times.
Which signal should I use? | true | 13,999,970 | 1.2 | 0 | 0 | 0 | You need to connect your view to the dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) signal of the model:
This signal is emitted whenever the data in an existing item changes.
If the items are of the same parent, the affected ones are those
between topLeft and bottomRight inclusive. If the items do not have
the same parent, the behavior is undefined.
When reimplementing the setData() function, this signal must be
emitted explicitly. | 0 | 5,032 | 0 | 3 | 2012-12-22T04:07:00.000 | python,qt,user-interface,qt4,pyqt | PyQt - Automatically refresh a custom view when the model is updated? | 0 | 1 | 2 | 14,000,161 | 1 |
0 | 0 | I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt).
EDIT
This code will reproduce the bug:
sc = curses.initscr()
sc.nodelay(1) # But removing this line allows the program to run properly
for angry in range(20):
sc.addstr(angry, 1, "hi")
Here's my full code
import curses, time, sys, random
def paint(x, y, i):
#...
def string(s, y):
#...
def feed():
#...
sc = curses.initscr()
curses.start_color()
curses.curs_set(0)
sc.nodelay(1) #########################################
# vars + colors inited
for angry in range(20):
try:
dir = chr(sc.getch())
sc.clear()
feed()
#lots of ifs
body.append([x, y])
body.pop(0)
for point in body:
paint(*point, i=2)
sc.move(height-1, 1)
sc.refresh()
time.sleep(wait)
except Exception as e:
print sys.exc_info()[0], e
sc.getch()
curses.beep()
curses.endwin()
Why is this happenning, and how can I use nodelay() safely? | false | 14,004,835 | 0.066568 | 0 | 0 | 1 | While I didn't use curses in python, I am currently working with it in C99, compiled using clang on Mac OS Catalina. It seems that nodelay()` does not work unless you slow down the program step at least to 1/10 of a second, eg. usleep(100000). I suppose that buffering/buffer reading is not fast enough, and getch() or wgetch(win*) simply doesn't manage to get the keyboard input, which somehow causes it to fail (no message whatsoever, even a "Segmentation fault").
For this reason, it's better to use halfdelay(1), which equals nodelay(win*, true) combined with usleep(100000).
I know this is a very old thread (2012), but the problem is still present in 2022, so I decided to reply. | 0 | 5,827 | 1 | 7 | 2012-12-22T17:13:00.000 | python,ncurses,curses | nodelay() causes python curses program to exit | 0 | 2 | 3 | 72,080,593 | 1 |
0 | 0 | I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt).
EDIT
This code will reproduce the bug:
sc = curses.initscr()
sc.nodelay(1) # But removing this line allows the program to run properly
for angry in range(20):
sc.addstr(angry, 1, "hi")
Here's my full code
import curses, time, sys, random
def paint(x, y, i):
#...
def string(s, y):
#...
def feed():
#...
sc = curses.initscr()
curses.start_color()
curses.curs_set(0)
sc.nodelay(1) #########################################
# vars + colors inited
for angry in range(20):
try:
dir = chr(sc.getch())
sc.clear()
feed()
#lots of ifs
body.append([x, y])
body.pop(0)
for point in body:
paint(*point, i=2)
sc.move(height-1, 1)
sc.refresh()
time.sleep(wait)
except Exception as e:
print sys.exc_info()[0], e
sc.getch()
curses.beep()
curses.endwin()
Why is this happenning, and how can I use nodelay() safely? | false | 14,004,835 | 0 | 0 | 0 | 0 | I see no difference when running your small test program with or without the sc.nodelay() line.
Neither case prints anything on the screen... | 0 | 5,827 | 1 | 7 | 2012-12-22T17:13:00.000 | python,ncurses,curses | nodelay() causes python curses program to exit | 0 | 2 | 3 | 14,006,585 | 1 |
0 | 0 | I need to store cookies persistently in an application that uses QWebKit. I understand that I have to create a subclass of QNetworkCookieJar and attach it to a QNetworkAccessManager. But how do I attach this QNetworkAccessManager to my QWebView or get the QNetworkAccessManager used by it?
I use Python 3 and PyQt if that is important. | true | 14,034,401 | 1.2 | 0 | 0 | 4 | You can get/set the cookie jar through QWebView.page().networkAccessManager().cookieJar()/setCookieJar().
The Browser demo included with Qt (in C++) shows how to read and write cookies to disk. | 0 | 1,268 | 0 | 3 | 2012-12-25T22:21:00.000 | python,qt,cookies,qwebkit | Permanent cookies with QWebKit -- where to get the QNetworkAccessManager? | 0 | 1 | 1 | 14,039,648 | 1 |
0 | 0 | I'm using DataViewListCtrl and i add itemswith
AppendItem(["test123"])
How can i add data associated with each item? | false | 14,043,470 | 0.197375 | 0 | 0 | 2 | Old question, I know, but there should be an answer.
AppendItem(["test123", "data for second column", "third column", "etc..."]) | 0 | 1,889 | 0 | 1 | 2012-12-26T16:44:00.000 | wxpython | WxPython DataViewListCtrl item data | 0 | 1 | 2 | 36,878,217 | 1 |
0 | 0 | I'm designing a "settings" frame for a Python/Tkinter app that lets the user specify an IP address, port number, and a couple other configurable options. I want to validate the user entries before letting the user close the frame to apply them.
Based on what I've read up on (and tried) so far with the Entry widget's validate and validatecommand options, the only choices they offer are "heavy-handed" validations. The kind where the user is blocked from leaving the Entry widget (or even typing any more keystrokes) until the entry is valid. This is exactly the behavior I avoid when designing a GUI because it's annoying as all get-out for the user.
I'm planning on switching over to using .trace methods to keep watch on the values, and just disabling the "OK/Apply" button until all of the entries in the frame are valid. Before I do that though, I wanted to know whether I'm missing anything with regards to the built-in validation options. Is there an option I missed that's less heavy-handed? | false | 14,055,551 | 0.132549 | 0 | 0 | 2 | You can use the validation feature without the "heavy-handedness". Have your validation always return True after setting the state of the ok/apply button. | 0 | 471 | 0 | 0 | 2012-12-27T13:32:00.000 | python,tkinter | Does Tkinter validation have to be heavy-handed? | 0 | 2 | 3 | 14,056,624 | 1 |
0 | 0 | I'm designing a "settings" frame for a Python/Tkinter app that lets the user specify an IP address, port number, and a couple other configurable options. I want to validate the user entries before letting the user close the frame to apply them.
Based on what I've read up on (and tried) so far with the Entry widget's validate and validatecommand options, the only choices they offer are "heavy-handed" validations. The kind where the user is blocked from leaving the Entry widget (or even typing any more keystrokes) until the entry is valid. This is exactly the behavior I avoid when designing a GUI because it's annoying as all get-out for the user.
I'm planning on switching over to using .trace methods to keep watch on the values, and just disabling the "OK/Apply" button until all of the entries in the frame are valid. Before I do that though, I wanted to know whether I'm missing anything with regards to the built-in validation options. Is there an option I missed that's less heavy-handed? | false | 14,055,551 | 0.066568 | 0 | 0 | 1 | If you use trace, then you have what you want without needing to use Tkinter's validation at all. Make all traces go to the same function, where you test and validate all your values as you wish, and according to that enable or disable the ok button. | 0 | 471 | 0 | 0 | 2012-12-27T13:32:00.000 | python,tkinter | Does Tkinter validation have to be heavy-handed? | 0 | 2 | 3 | 14,055,762 | 1 |
0 | 0 | So my App needs to be able to open a single webpage(and it must be from the internet and not saved) in it, and specifically I'd like to use the Tkinter GUI toolkit since it's the one i'm most comfortable with. On top of that though, I'd like to be able to generate events in the window(say a mouse click) but without actually using the mouse. What's a good method to go about this?
EDIT: I suppose to clarify this a bit, I need a way to load a webpage, or maybe even a specific java applet into a tkinter widget or window. Or if not that perhaps another method to do this where I can generate mouse and keyboard events without using either the mouse of the keyboard. | false | 14,076,674 | 0.099668 | 0 | 0 | 2 | Tkinter does not have a widget that can render a web page. | 0 | 8,422 | 0 | 4 | 2012-12-28T22:38:00.000 | python,tkinter | Using Tkinter to open a webpage | 0 | 1 | 4 | 14,077,404 | 1 |
1 | 0 | I am using python webkit.WebView and gtk to crawl a web page. However, the web page is kind of dynamically loaded by javascript.
The WebView "load-finished" event is not sufficient to handle this. Is there any indicator/event to let me know that the page is really fully loaded even the content produced by javascript?
Thanks, | true | 14,093,870 | 1.2 | 0 | 0 | 4 | There is no real way to determine if that page is fully loaded.
One method is to determine the amount of time since the last request. However, some pages will make repeated requests continually. This is common with tracking scripts and some ad scripts.
What I would do is use a set amount of time after the web view has said it finished loading... 5 seconds or so. It isn't perfect, but is the best you got, as there is no way to determine what "fully loaded" is for an arbitrary page. | 0 | 218 | 0 | 6 | 2012-12-30T19:26:00.000 | javascript,python,webview,webkit,web-crawler | How do I know a page is really fully loaded? | 0 | 1 | 1 | 14,094,212 | 1 |
0 | 0 | I was working with GUI automation for visual studio C# desktop application.
There I have DataGridView and inside the grid I have combo box and check boxes.
I tried to automate these using pywinauto, I can get only grid layout control only
and internal things I cant able to get the controls
(I tried with print _control_identifiers() , Swapy, AutoIT Window Info and winspy also..)
anyone plz tell me how to automate visual studio C# DataGridView and its sub controls using pywinauto for desktop application?? | false | 14,101,063 | 0.291313 | 0 | 0 | 3 | The short answer is that there's no good way to automate sub-controls of a DataGridView using PyWinAuto.
If you want to read data out of a DataGridView (e.g. read the text contents of a cell, or determine whether a checkbox is checked), you are completely out of luck. If you want to control a DataGridView, there are two approaches that you can try:
clicking at various coordinate offsets.
sending keypresses to it to mimic keyboard navigation.
These may work if your DataGridView has a small amount of data in it, but once the DataGridView starts needing scrollbars you're out of luck. Furthermore, clicking at offsets is sensitive to the sizes of the rows and columns, and if the columns can be resized then this approach will never be reliable. | 0 | 1,878 | 0 | 0 | 2012-12-31T11:36:00.000 | c#,python,ui-automation,pywinauto | C# GUI automation using PyWinAuto | 0 | 1 | 2 | 14,104,632 | 1 |
0 | 0 | I found some many Python GUI toolkits.
The ones I like are:
wxPython
pyGTK
Tkinter
pyQt
pySide
Which one is the best and easiest to use?
And by the way what is the difference in pyQt and pySide? They both seem to be alike :/. | true | 14,106,229 | 1.2 | 0 | 0 | 4 | There is no "best" nor "easiest". All of the toolkits you mention have strengths and weaknesses. I've had significant experience with wxPython and Tkinter, and both are nice. I would say Tkinter is a little easier, wxPython is a little more full-featured.
When someone asks me this question I tell them just to pick one. Once you learn one -- any one -- you'll be in a better position to decide for yourself which one is better than the others.
I recommend Tkinter just because you probably already have it, but if you're not afraid of installing other GUI toolkits, pick any of them and start coding. | 0 | 8,808 | 0 | 6 | 2012-12-31T21:35:00.000 | python,python-2.7,user-interface | Which is the best and easiest Python GUI toolkit? | 0 | 1 | 1 | 14,106,272 | 1 |
0 | 0 | I have question and want to see if it can be realized in wxpython.
I would like to plot data on wxpython, and then use the mouse to select some points which are plotted, using the mouse.
At the moment i am using wx.lib.plot and using the PlotMarker
Is there a way of doing this with wx.lib.plot or do i have to use another graph library
Regards! | false | 14,138,946 | 0 | 0 | 0 | 0 | You can use matplotlib or pygal. Something similar with your describing technique is used in PyQtGraph. | 0 | 944 | 0 | 0 | 2013-01-03T12:27:00.000 | python | interactive graph python wx.lib.plot. selecting some points | 0 | 1 | 3 | 14,139,047 | 1 |
0 | 0 | I made an app with PySide. When ever I run the app the GUI shows up but the CMD window is still there too. How do I hide it? | true | 14,139,190 | 1.2 | 0 | 0 | 1 | Run the app using pythonw it will hide the window | 0 | 228 | 0 | 1 | 2013-01-03T12:43:00.000 | python,qt,python-2.7,pyside | How to hide the CMD window in PySide app | 0 | 1 | 1 | 14,139,249 | 1 |
0 | 0 | i'm looking for a solution, either in linux or in windows, that allows me to
record video (+audio) from my webcam & microphone, simultaneously.
save it as a file.AVI (or mpg or whatever)
display the video on the screen while recording it
Compression is NOT an issue in my case, and i actually prefer to capture RAW and compress it later.
So far i've done it with an ActiveX component in VB which took care of everything, and i'd like to progress with python (the VB solution is unstable, unreliable).
so far i've seen code that captures VIDEO only, or individual frames...
I've looked so far at
OpenCV - couldn't find audio capture there
PyGame - no simultaneous audio capture (AFAIK)
VideoCapture - provide only single frames.
SimpleCV - no audio
VLC - binding to VideoLAN program into wxPthon - hopefully it will do (still investigating this option)
kivy - just heard about it, didn't manage to get it working under windows SO FAR.
The question - is there a video & audio capture library for python?
or - what are the other options if any? | false | 14,140,495 | 0 | 0 | 0 | 0 | You can do offline html,js code to do video with audio recording. Using python lib python webview open that page. It should work fine. | 0 | 75,201 | 0 | 29 | 2013-01-03T14:08:00.000 | python,video-capture | How to capture a video (AND audio) in python, from a camera (or webcam) | 0 | 1 | 7 | 68,495,610 | 1 |
0 | 0 | Does anyone know of a GUI design app that lets you choose/drag/drop the widgets, and then turn that layout into Python code with the appropriate Tkinter calls & arrangement using the grid geometry manager? So far I've turned up a couple of pretty nice options that I may end up using, but they generate code using either pack or place instead.
=========
EDIT: Please note this is not to seek a "recommendation" per se, but rather it is a factual inquiry. I was asking whether or not such an app exists.
=====
Before you say it: Yes, I know Tkinter is easy to learn, and Yes, I've found multiple online sources to help me do so, and I'm already on my way with that. This isn't about avoiding the effort of learning, it's about using the right tool for the job. I found out a long time ago that those drag-and-drop widget environments for coding program logic, are just too klunky and unmanageable when the project gets beyond a certain size -- for bigger stuff, it's just easier to build and maintain the logic when it's in plain text. More recently I've found out that the reverse is true for designing a GUI. Writing text works up to a point, but when you have a main window with 30 or 40 widgets, plus a couple of side windows each with similar complexity, it goes much faster and easier if you can design it graphically rather than typing it all out. | false | 14,142,194 | 1 | 0 | 0 | 30 | The best tool for doing layouts using grid, IMHO, is graph paper and a pencil. I know you're asking for some type of program, but it really does work. I've been doing Tk programming for a couple of decades so layout comes quite easily for me, yet I still break out graph paper when I have a complex GUI.
Another thing to think about is this: The real power of Tkinter geometry managers comes from using them together*. If you set out to use only grid, or only pack, you're doing it wrong. Instead, design your GUI on paper first, then look for patterns that are best solved by one or the other. Pack is the right choice for certain types of layouts, and grid is the right choice for others. For a very small set of problems, place is the right choice. Don't limit your thinking to using only one of the geometry managers.
* The only caveat to using both geometry managers is that you should only use one per container (a container can be any widget, but typically it will be a frame). | 0 | 150,823 | 0 | 59 | 2013-01-03T15:44:00.000 | python,grid,tkinter | Is there a GUI design app for the Tkinter / grid geometry? | 0 | 1 | 3 | 14,144,121 | 1 |
0 | 0 | My PyGTK application creates a secondary popup window for displaying a preview of results. This window is fairly elaborate, with Table widgets nested three deep and populated by HBoxes containing one Label each at the lowest level. The number of Labels total can be in the thousands. I am noticing that when I close this window, GTK becomes extremely busy processing something (functions added with gobject.idle_add don't resolve for >10 seconds) and the main window of my application becomes unresponsive in this time. Even with this many widgets, it seems strange to me that the window should take so long to close, longer even than it takes to set up and display. Is there any way to mitigate this? (I tried creating and showing the window in another thread, but apparently with GTK this is a no-no) | true | 14,147,434 | 1.2 | 0 | 0 | 0 | Apparently it was being caused by my attempt to change the background color of the tables--I was setting the background color of every HBox (and Label), which was responsible for nearly all of the excessive teardown time. All I had to do was set the background color of the Viewports the Tables are contained in. | 0 | 88 | 0 | 0 | 2013-01-03T21:20:00.000 | python,gtk | Excessive hang time when destroying a PyGTK window | 0 | 2 | 2 | 14,160,390 | 1 |
0 | 0 | My PyGTK application creates a secondary popup window for displaying a preview of results. This window is fairly elaborate, with Table widgets nested three deep and populated by HBoxes containing one Label each at the lowest level. The number of Labels total can be in the thousands. I am noticing that when I close this window, GTK becomes extremely busy processing something (functions added with gobject.idle_add don't resolve for >10 seconds) and the main window of my application becomes unresponsive in this time. Even with this many widgets, it seems strange to me that the window should take so long to close, longer even than it takes to set up and display. Is there any way to mitigate this? (I tried creating and showing the window in another thread, but apparently with GTK this is a no-no) | false | 14,147,434 | 0.099668 | 0 | 0 | 1 | How long takes that window to show up? Are all the widgets created at once when it is displayed?
Your problem might be caused by the destruction of your thousands of widgets, all at the same time. Or by a lengthy action perform on on of those widgets destruction. But without some code to look at, there could be thousands of reasons, so a ptomato says, use a profiler... | 0 | 88 | 0 | 0 | 2013-01-03T21:20:00.000 | python,gtk | Excessive hang time when destroying a PyGTK window | 0 | 2 | 2 | 14,156,870 | 1 |
0 | 0 | So I have an assignment in Computer Science that requires that I put an interactive menu into my python turtle graphics projects. I run on python 2.7.3 and would like some help on what modules to import and a basic outline of how to put an interactive menu into python turtle graphics. Thank you for your answers! | false | 14,177,297 | 0 | 0 | 0 | 0 | In 3.x, look at Lib/turtledemo/main.py for how to put a turtle canvas into a tkinter window with other stuff. In 2.x, the turtledemo main code is in Demo/turtle/turtleDemo.py in the source repository, but the Demo directory is not installed on Windows. | 0 | 1,224 | 0 | 1 | 2013-01-05T22:53:00.000 | menu,python-2.7,python-idle,turtle-graphics,cheeseshop | How to Insert an Interactive Menu into Python Turtle Graphics | 0 | 1 | 1 | 26,772,106 | 1 |
0 | 0 | I call foreign c library in my program using ctypes, I don't know how to assign a POINTER(c_char) variant to a string. | false | 14,191,462 | 0 | 0 | 0 | 0 | The question is vague, but I guess you should use c_char_p instead of POINTER(c_char). | 0 | 149 | 0 | 0 | 2013-01-07T07:12:00.000 | python,python-2.7 | How can I assign a variant of POINTER(c_char) type to a string? | 0 | 1 | 1 | 14,193,534 | 1 |
0 | 0 | I'm looking at a way to take screenshot of DirectX games in Python. I already tried to use PIL and other stuff but I only end up with black screenshots. I saw that the project directpython11 provided a Python binding to some DirectX stuff but I didn't find anything related to screenshot of external DirectX applications.
I'm kinda lost and any help will be much appreciated ;).
PS: I'm coding using Python 2.7.3 32 bits on Windows 7.
Thanks | false | 14,205,113 | 0.761594 | 0 | 0 | 5 | This is a rather complicated topic.
Actually taking a screenshot, in the most simplistic way, involves grabbing the backbuffer and writing that to a file. Your Python DirectX bindings should provide support for making a texture and filling it with data, from the back or front buffer; after that the image writing is up to you.
Unfortunately, getting to the backbuffer requires hooking DirectX and intercepting the render context before the application gets ahold of it. While simple, this is not terribly well-documented and takes a decent bit of (C++) code to implement. You have to force the application to use an alternate render context which you control, then take the screenshot yourself.
The basics of this interception cannot, so far as I know, be done in pure Python. You may be able to find a method using the display codec (grabbing the screen after it's been delivered to the compositor), or you could use an existing DirectX hook and implement minimal IPC to grab the data and feed it into Python for processing and writing to a file.
Edit: If you are interested in doing this, I can add more detail and some links to code that may be helpful. I'm still not sure it's possible in just Python, but don't let that stop you from trying. | 0 | 2,931 | 0 | 2 | 2013-01-07T22:21:00.000 | python,directx,screenshot | Take a screenshot of a DirectX game in Python | 0 | 1 | 1 | 14,205,237 | 1 |
0 | 0 | I manage a number of Windows PCs which are used to control equipment. Each computer has a specific program installed which is what people launch to use that equipment. We want to require people to log in before they can access this program.
Currently, I have a wxpython app which just launches that executable when people log in with the correct credentials. However, you can just run the program directly and bypass logging on. I'd like to make a mock logon screen, ie, fullscreen and modal, which only goes away when you log in. Also it should not be able to be bypassed by alt-tab, windows key, etc. How might I accomplish this with wxpython? | true | 14,206,982 | 1.2 | 0 | 0 | 1 | There is no full proof way to do this on Windows. You can show a wx.Frame modally using its MakeModal() method. And you can catch EVT_CLOSE and basically veto it it they try to close the frame. However, if they have access to the Task Manager or even Run, they can probably get around the screen. Most users won't be that smart though. You can delete the shortcuts to the apps you want to launch with wx and that will force most normal users to use your login screen. It's only the smart ones who like to troll through the file system who will go around it. | 0 | 95 | 0 | 0 | 2013-01-08T01:35:00.000 | windows,authentication,wxpython,modal-dialog | Logon-type wxpython app | 0 | 1 | 1 | 14,217,396 | 1 |
0 | 0 | This is one of those just-making-sure-I-didn't-miss-anything posts.
I have a TKinter GUI in Python 2.7.3 that includes a listbox, and there are circumstances where I'd like to directly modify the text of a specific item at a known index. I've scoured the documents and there's no lb.itemset() method or anything like it. As best I can tell I have two options, either of which would work but just seem kind of klunky to me:
lb.delete() the old item and lb.insert() the new value for it at the same index (including a step to re-select the new value if the old deleted one happened to be selected).
Create a listvariable for the listbox, then use get() and set() on it -- with a pile of replace/split/join acrobatics in between to handle the differing string formats involved.
Is there some simpler, more direct way to do it that I'm missing? Or have I turned up all the available options? | true | 14,222,670 | 1.2 | 0 | 0 | 2 | Assuming from silence that there's nothing I missed. I went with option 2 -- the acrobatics weren't quite as complex as I'd thought. I just created a behind-the-scenes list wrapped up in a class; every time I update the list, the class syncs up the content of the listbox by doing a ' '.join on the list then setting the listbox's listvariable to the resulting string. | 0 | 1,274 | 0 | 3 | 2013-01-08T19:34:00.000 | listbox,python-2.7,tkinter | Directly modify a specific item in a TKinter listbox? | 0 | 1 | 1 | 14,251,259 | 1 |
0 | 1 | I am looking for a library, example or similar that allows me to loads a set of 2D projections of an object and then converts it into a 3D volume.
For example, I could have 6 pictures of a small toy and the program should allow me to view it as a 3D volume and eventually save it.
The object I need to convert is very similar to a cylinder (so the program doesn't have to 'understand' what type of object it is). | false | 14,232,451 | 0.379949 | 0 | 0 | 2 | There are several things you can mean, I think none of which currently exists in free software (but I may be wrong about that), and they differ in how hard they are to implement:
First of all, "a 3D volume" is not a clear definition of what you want. There is not one way to store this information. A usual way (for computer games and animations) is to store it as a mesh with textures. Getting the textures is easy: you have the photographs. Creating the mesh can be really hard, depending on what exactly you want.
You say your object looks like a cylinder. If you want to just stitch your images together and paste them as a texture over a cylindrical mesh, that should be possible. If you know the angles at which the images are taken, the stitching will be even easier.
However, the really cool thing that most people would want is to create any mesh, not just a cylinder, based on the stitching "errors" (which originate from the parallax effect, and therefore contain information about the depth of the pictures). I know Autodesk (the makers of AutoCAD) have a web-based tool for this (named 123-something), but they don't let you put it into your own program; you have to use their interface. So it's fine for getting a result, but not as a basis for a program of your own.
Once you have the mesh, you'll need a viewer (not view first, save later; it's the other way around). You should be able to use any 3D drawing program, for example Blender can view (and edit) many file types. | 0 | 1,288 | 0 | 0 | 2013-01-09T09:53:00.000 | python,image-processing,3d,2d | 2D image projections to 3D Volume | 0 | 1 | 1 | 14,233,016 | 1 |
0 | 0 | I have a notebook window. I want to change dynamically size. I did expand dynamically, but I couldn't shrink it. I used win.set_size_request(w,h) for expand. How can I shrink dynamically? | false | 14,236,918 | 0 | 0 | 0 | 0 | You likely have widgets on your pages that are stopping them from shrinking. You may need to put the content of your pages in a ViewPort or ScrolledWindow to get the effect you are looking. | 0 | 329 | 0 | 0 | 2013-01-09T14:00:00.000 | python,gtk | Gtk Notebook size dynamically change | 0 | 1 | 2 | 14,327,100 | 1 |
0 | 0 | I haven't seen an example of this but I wanted to know if any knows how to implement a colorbar with an adjustable slider using wxpython. Basically the slider should change the levels of the colorbar and as such adjust the colormap.
If anyone has an idea of how to do and possible some example code it would be much appreciated. | true | 14,244,195 | 1.2 | 0 | 0 | 1 | I think you're looking for one of the following widgets:
ColourDialog, ColourSelect, PyColourChooser or CubeColourDialog
They all let you choose colors in different ways and they have a slider to help adjust the colours too.
You can see each of them in action in the wxPython demo (downloadable from the wxPython web page) | 0 | 386 | 0 | 0 | 2013-01-09T18:41:00.000 | python,slider,wxpython,color-mapping | colorbar with a slider using wxpython | 0 | 1 | 1 | 14,260,324 | 1 |
0 | 0 | I have a text widget with dark background and I can't see the cursor's position. Is there any way to change the (blinking) text cursor's color? | true | 14,284,492 | 1.2 | 0 | 0 | 30 | You can change the insertbackground option of the text widget to whatever you want. | 0 | 12,336 | 0 | 21 | 2013-01-11T18:32:00.000 | python,tkinter,colors,text-cursor | How to change text cursor color in Tkinter? | 0 | 1 | 3 | 14,284,594 | 1 |
0 | 0 | I'm a Python guy building a Linux-based web service for a client who wants me to interface with a small C++ library that they're currently using with a bunch of Windows based VB applications.
They have assured me that the library is fairly simple (as far as they go I guess), and that they just need to know how best to compile and deliver it to me so that I can use it in Python under Linux.
I've read a bit about the ctypes library and other options (SWIG, etc), but for some reason I haven't really been able to wrap my head around the concept and still don't know how to tell them what I need.
I'm pretty sure having them re-write it with Python.h, etc is out, so I'm hoping there's a way I can simply have them compile it on Linux as a .so and just import it into Python. Is such a thing possible? How does one accomplish this? | false | 14,289,656 | 0 | 0 | 0 | 0 | Due to complexities of the C++ ABI (such as name mangling), it's generally difficult and platform-specific to load a C++ library directly from Python using ctypes.
I'd recommend you either create a simple C API which can be easily wrapped with ctypes, or use SWIG to generate wrapper types and a proper extension module for Python. | 0 | 201 | 0 | 0 | 2013-01-12T02:41:00.000 | c++,python | How does one get a C++ library loaded into Python as a shared object file (.so)? | 0 | 1 | 2 | 14,289,688 | 1 |
0 | 0 | I was using PIL to do image processing, and I tried to convert a color image into a grayscale one, so I wrote a Python function to do that, meanwhile I know PIL already provides a convert function to this.
But the version I wrote in Python takes about 2 seconds to finish the grayscaling, while PIL's convert almost instantly. So I read the PIL code, figured out that the algorithm I wrote is pretty much the same, but
PIL's convert is written in C or C++.
So is this the problem making the performance's different? | false | 14,289,657 | 0.291313 | 1 | 0 | 3 | Yes, coding the same algorithm in Python and in C, the C implementation will be faster. This is definitely true for the usual Python interpreter, known as CPython. Another implementation, PyPy, uses a JIT, and so can achieve impressive speeds, sometimes as fast as a C implementation. But running under CPython, the Python will be slower. | 1 | 318 | 0 | 0 | 2013-01-12T02:41:00.000 | python,c,python-imaging-library | performance concern, Python vs C | 0 | 2 | 2 | 14,289,791 | 1 |
0 | 0 | I was using PIL to do image processing, and I tried to convert a color image into a grayscale one, so I wrote a Python function to do that, meanwhile I know PIL already provides a convert function to this.
But the version I wrote in Python takes about 2 seconds to finish the grayscaling, while PIL's convert almost instantly. So I read the PIL code, figured out that the algorithm I wrote is pretty much the same, but
PIL's convert is written in C or C++.
So is this the problem making the performance's different? | false | 14,289,657 | 0.197375 | 1 | 0 | 2 | If you want to do image processing, you can use
OpenCV(cv2), SimpleCV, NumPy, SciPy, Cython, Numba ...
OpenCV, SimpleCV SciPy have many image processing routines already.
NumPy can do operations on arrays in c speed.
If you want loops in Python, you can use Cython to compile your python code with static declaration into an external module.
Or you can use Numba to do JIT convert, it can convert your python code into machine binary code, and will give you near c speed. | 1 | 318 | 0 | 0 | 2013-01-12T02:41:00.000 | python,c,python-imaging-library | performance concern, Python vs C | 0 | 2 | 2 | 14,290,456 | 1 |
0 | 0 | Is there a method to add python pygame with images to PHP and display it in a local browser? What are the necessary requirements to do something like this? | false | 14,296,401 | 0 | 0 | 0 | 0 | If I got you right, then answer is: no, it's impossible. I think — Flash is most acceptable choice for you, or Unity3D with browser plugin. | 0 | 71 | 0 | 0 | 2013-01-12T18:12:00.000 | php,python,pygame | Is there a way to add Pygame into a local PHP file? | 0 | 1 | 1 | 14,296,430 | 1 |
0 | 0 | Can anybody tell me how I can return the dimensions of a video (pixel height/width) using Qt (or any other Python route to that information). I have googled the hell out of it and cannot find a straight answer.
I assumed it would either be mediaobject.metadata() or os.stat() but neither appear to return the required info. | true | 14,323,390 | 1.2 | 0 | 0 | 0 | OK - for others out there looking for the same info, I found Hachoir-metadata and Hachoir-parser (https://bitbucket.org/haypo/hachoir/wiki/Home).
They provide the correct info but there is a serious lack of docs for it and not that many examples that I can find. Therefore, while I have parsed a video file and returned the metadata for it, I'm now struggling to 'get' that information in a usable format. However, I will not be defeated! | 0 | 305 | 0 | 0 | 2013-01-14T17:21:00.000 | python,qt,video,pyside,phonon | qt phonon - returning video dimensions | 0 | 1 | 3 | 14,509,771 | 1 |
0 | 0 | I want disable dragging the wx.Dialog. I noticed when I remove the caption the user can not drag the dialog, but I want to keep the caption. Any suggestions would be helpful? Thank you. | false | 14,362,863 | 0 | 0 | 0 | 0 | The only way to do it is to remove the caption as you've already found. You might be able to use a wx.Timer or catch a dragging event of some sort and center the dialog that way, but otherwise, removing the caption is the way to go. | 0 | 139 | 0 | 2 | 2013-01-16T16:18:00.000 | wxpython,wxwidgets | How to disable dragging wx.DIalog from the user | 0 | 1 | 1 | 14,363,626 | 1 |
0 | 0 | EDIT: Can someone explain why this is "Off Topic"? I think it very clearly follows the guidelines laid out in the FAQ. Is there something I'm missing?
I've been creating a windows desktop application in PyQt (python 2.7, PyQt 4.9.5), and I'm getting close to releasing the software for sale. It's time for me to add some sort of system for licensing/serial number based software activation. The software is a business to business product with a retail price of around $250.
I've been looking at going with Fastspring and they offer integration with:
AquaticPrime
CocoaFOB
GameShield and Software Passport
Yummy Interactive's SoftwareShield
Soraco's Quick License Manager
Softwrap
Concept Software's SoftwareKey System
What are some good options for providing this functionality? Some things I've run into is that none of them seem to provide a python API, so I'd have to figure out how to integrate their stuff with my python code. I've never had to do that, so ease of integration with Python would be a strong factor, as would cost. I don't feel a strong need to prevent anyone from pirating my software, I just want to keep businesses honest so that they buy the correct number of seats. A final thing to consider is that in the future I might want to make it cross platform and ideally I wouldn't be locking myself to just windows.
Thanks for your help. | false | 14,388,482 | 0.379949 | 0 | 0 | 2 | One thing to note is that it is relatively easy to decompile and reverse engineer Python bytecode and remove any protection you put into it, so it's usually not worth it to spend too much effort and time on implementing a crack-proof protection. You just want to put enough to keep people honest.
If your concern is that businesses buy the correct number of seats, one basic protection mechanism is to use a public key mechanism to put a digital signature to a message using a private key on your licensing server. The message is just a random string and some uniquely identifying information that restricts the machine that the license key is valid for (e.g. MAC address, etc), and perhaps a timestamp if you want to expire the key. This message and the signature is then encoded in a string that your customers put into your program, which validate the license key by verifying that signature matches the message and the message matches the machine.
There are simpler schemes if all you care is that the user has a key (not that they have a different key for different machines); you can simply use a totally random string for the message.
This scheme is secure as long as the user does not reverse engineer your code. It can be bypassed by reverse engineering the public key in your program with their own public key. It can also be bypassed by tampering the information used to identify the computer, e.g. MAC address; tampering these informations may allow multiple installations using the same key. | 0 | 3,211 | 0 | 4 | 2013-01-17T21:30:00.000 | python,licensing | What serial number licensing solution should I use for a Python application with Fastspring? | 0 | 1 | 1 | 14,420,183 | 1 |
0 | 0 | Im a newbie to Wxpython programming and I have a general on how to make my application more program.
Assume, I have a tree with the list of employees being listed in the tree. When I click a employee the information is retrieved in the db and the information is diplayed on the right side of the panel.
Now, when I edit information of one of the employee and save it again the data the current row in the table needs to be end dated and the new row will be created in the db and also refreshing the tree.
So, Basically if something is saved the tree should be refreshed automatically. How do I accomplish this? | false | 14,430,915 | 0 | 0 | 0 | 0 | I don't believe the default TreeCtrl has database interaction builtin. You would have to add that. If you want it to check for updates periodically, you could use a wx.Timer. If you'll be updating the database with your wxPython GUI, then there shouldn't be a problem as you'll have to update the display anyway.
You might also want to look at the DVC_DataViewModel in the wxPython demo. I think it may make this sort of thing easier as it has the concept of data objects, which I think implies that you could create a database object to feed your GUI. | 0 | 115 | 0 | 0 | 2013-01-21T00:23:00.000 | wxpython | Wxpython dynamic programming | 0 | 1 | 1 | 14,460,784 | 1 |
0 | 0 | I'm using the QComboBox to let the user select a very large quantity of choices. For the moment the user can type a character and the QComboBox selects the first row with this character, but I feel that it's just not enough.
Is there any thing already done for the user to search directly the item by entering a text?
Thanks | true | 14,437,549 | 1.2 | 0 | 0 | 2 | You can use void QComboBox::setCompleter(QCompleter *completer) | 0 | 568 | 0 | 0 | 2013-01-21T11:21:00.000 | python,qt,pyqt,qcombobox | Quick find item with QComboBox in Qt | 0 | 1 | 1 | 14,437,632 | 1 |
0 | 0 | I need some help, I am coding a Zip password Cracker.I am trying to create a gui interface for my cracker.
I want to show a message box for right password if founded in password file..
But, showinfo message box is not executing after clicking on crack button, while if i am printing password using print it is working..
So, help me why showinfo message box is not executing.
Here, | false | 14,439,001 | 0 | 0 | 0 | 0 | You cannot call Tkinter commands from any thread other than the main thread. Tkinter is not thread safe. | 0 | 150 | 0 | 0 | 2013-01-21T12:48:00.000 | python,python-2.7,tkinter | Python-Help in Tkinter | 0 | 1 | 1 | 14,441,255 | 1 |
0 | 0 | I'd like a Python-accessible function show_image(...) that launches a fairly simple image viewer, where the image is specified as (for example) a NumPy array. Importantly, I'd like for this function not to block, but for the script to continue execution while maintaining interactivity of the window.
I realize that the giant design flaw and all around pain-in-the-ass known as the Global Interpreter Lock will thwart any Python-based GUI running in parallel with Python code in the main thread, so I'd obviously need to launch a thread that releases the GIL and does everything in C/C++.
I'm comfortable wrapping such a thing with Cython (or in a handwritten C extension module) but I'm looking for the right GUI solution. It should be cross-platform and easy to build in conjunction with a Cython extension (the latter of which seemingly rules out Qt/qmake/etc.)
Importantly, I'd like to be able to launch multiple windows this way, on demand. It seems that most GUI toolkits have some run()-like function that needs to be called at the end of the main thread program's main(), making it not terribly clear to me how I'd go about launching a window more than once. I guess I could launch a separate GUI event loop every time, but that seems like a recipe for disaster (as I recall, it is explicitly unsupported by GTK+, at least).
I'll also say that fork()'ing is not an option. | false | 14,446,488 | 0 | 0 | 0 | 0 | Personally I use os.system("xv foo.png &"), or any small image viewer. Depending on the details, you may also do g = os.popen("xv - &", "w") and write the image data to the file g. Again depending on the details, I sometimes make my program a web server (a few dozen lines of code, e.g. with Twisted), serve images from there, and view them in my web browser. My point is that you don't need any GUI or multithreading at all. | 0 | 864 | 0 | 1 | 2013-01-21T20:16:00.000 | python,image,user-interface | Non-blocking image viewer function from Python? | 0 | 1 | 1 | 14,446,771 | 1 |
0 | 0 | I have populated a combobox with an QSqlQueryModel. It's all working fine as it is, but I would like to add an extra item to the combobox that could say "ALL_RECORDS". This way I could use the combobox as a filtering device.
I obviously don't want to add this extra item in the database, how can I add it to the combobox after it's been populated by a model? | false | 14,455,871 | 0.099668 | 0 | 1 | 1 | You could use a proxy model that takes gets it's data from two models, one for your default values, the other for your database, and use it to populate your QComboBox. | 0 | 243 | 0 | 1 | 2013-01-22T10:02:00.000 | python,qt,pyqt,pyqt4,pyside | Adding an item to an already populated combobox | 0 | 1 | 2 | 14,540,595 | 1 |
0 | 0 | I'm writing a program and I need to inform the user about some changes with a popup message, but not a popup window. Something like the rectangle informing about new message in Kadu - no window, just a bitmap drawn directly on the screen for a few seconds.
I wonder if there is a simple way to do that with win32 package or Tkinter, and handle the event when the user clicks on the rectangle.
Actually the message would be constant, so the bitmap might be loaded from a file, but I still don't know how to start.
Any ideas, please?
Regards, mopsiok | false | 14,490,753 | 0 | 0 | 0 | 0 | I am using wxPython and looking for a way to have a popup message. Now I am using a popupmenu in which I append each item of the menu with one line of the message. | 0 | 1,969 | 0 | 0 | 2013-01-23T22:42:00.000 | python,popup,screen,draw | Python - popup message drawn on the screen | 0 | 1 | 2 | 15,838,631 | 1 |
0 | 0 | Someone know if it's possible to change the color of a pixel in a canvas without using un object, so without using something like canvas.create_oval or canvas.create_rectangle ? | false | 14,491,092 | 0.379949 | 0 | 0 | 4 | There is no way to color a pixel other than to create a 1x1 pixel object of some sort. And yes, at some point you will experience performance problems. The canvas simply wasn't designed to be used this way.
If you're really needing to create a large area in which you can manage individual pixels, you can create a canvas with a single image that is the same size as the canvas. You can then set the color of individual pixels on the image through the photo image interface. | 0 | 3,101 | 0 | 1 | 2013-01-23T23:07:00.000 | python,canvas,tkinter | Change the color of a pixel in a canvas, Tkinter, Python | 0 | 2 | 2 | 14,500,936 | 1 |
0 | 0 | Someone know if it's possible to change the color of a pixel in a canvas without using un object, so without using something like canvas.create_oval or canvas.create_rectangle ? | true | 14,491,092 | 1.2 | 0 | 0 | 0 | Within tkinter itself, it's impossible.
Even if you manage to change a pixel on canvas window (which is possible with X11 and Windows APIs in a platform-dependent way), you'd have to ensure it's repainted properly.
You can, of course, place a frame of size 1x1 over the canvas, with a background color you want. This way, pixel is "changed" and no canvas object is created. If there's a real (though strange) problem behind a question, this trick could be a solution. | 0 | 3,101 | 0 | 1 | 2013-01-23T23:07:00.000 | python,canvas,tkinter | Change the color of a pixel in a canvas, Tkinter, Python | 0 | 2 | 2 | 14,491,248 | 1 |
0 | 0 | I am using pycairo (actually cairocffi) on Ubuntu 12.04.
The library on the system is cairo 1.10.
I've created an empty ImageSurface, having an ARGB32 format.
If, for example, I try to fill a semi-transparent white rectangle (RGBA(1,1,1,0.5)), I see a semi-transparent grey rectangle.
This is the same for every semi-transparent pixel drawn on a semi-transparent background : it seems cairo considers that blending with a transparent pixel is the same thing as blending with a black pixel...
The same issue applies to antialiased shapes drawn on transparent surfaces: they have dark unexpected borders.
There is no reference to this behaviour, nowhere. So I am wondering, is this the expected behaviour of cairo ? How can I fix this ? | true | 14,514,438 | 1.2 | 0 | 0 | 2 | I have finally found what was wrong with cairo and the bad alpha blending.
Cairo supports ARGB32 surface, but only with premultiplied alpha.
That is, every component of a pixel is stored premultiplied with the alpha component.
I have not found an answer for this over the internet, and I assume premultiplied alpha is not suited for the type of operation I'm doing.
I switched to PyQt4, used ARGB32 images without premultiplication, and it worked like a charm.
I also tried with PyQt4 premultiplied alpha images, and reproduced the problem. | 0 | 835 | 0 | 3 | 2013-01-25T02:33:00.000 | python,cairo,pycairo | Cairo, ImageSurface : Cannot get correct alpha blending | 0 | 1 | 1 | 14,521,313 | 1 |
0 | 0 | I'm a newbie in this type of approach to programming since I really doesn't care for hardcore graphics generation. I design, write, run, and study parametrized climate models with python. But, at last, I have encountered myself with a visualization issue.
I was looking for something in Cairo library that allows me to map a linear gradient onto an arbitrary curve (not necessarily a circumference) such that there is a more or less smooth variation of colour (or shade) across my path. Then I have been looking for some pattern and I finally found that maybe mesh gradients in Cairo are the solution.
However, I can't create a new mesh gradient from my python script with cairo.pattern_create_mesh()!
Therefore, my questions are: How I use mesh gradients in Cairo? Is there any other simple way to do what I want with Cairo (I don't know, like a simple mapping from a line segment to a curve via parametrization, I know I ask too much)? | false | 14,518,005 | 0 | 0 | 0 | 0 | Mesh patterns were added in cairo 1.12 which is the latest release. Thus, most language bindings likely don't support them yet. I don't know anything about the combination of python and cairo and thus don't know any workaround.
I don't know any simple way to simulate what you need with other patterns, sorry. (Although I am not really sure how you want to do your mapping via mesh gradients either...) | 0 | 926 | 0 | 1 | 2013-01-25T08:26:00.000 | python-2.7,cairo,pycairo | Using mesh gradients in Cairo for coloring a path | 0 | 1 | 1 | 14,520,708 | 1 |
0 | 0 | I am new to designing GUIs in python and have a query:
Is there a way to have a label or any other widget with copyable text. I want to provide help section within GUI which will contain a sample xml to be given as input, I want user to be able to copy that xml.
I don't want that information to go away if user cuts that information, so I am not using a entry widget with pre-filled data.
Is there a way to achieve this?
Thanks! | false | 14,549,545 | 0.197375 | 0 | 0 | 1 | Use a text widget in disabled state.
There is no insertion cursor in this state, but the text may still be selected and copied (but not modified). | 0 | 254 | 0 | 0 | 2013-01-27T16:39:00.000 | python,user-interface,text,python-3.x,tkinter | Python tkinter GUI: which widget to use for having copyable text | 0 | 1 | 1 | 14,549,709 | 1 |
0 | 0 | An app I made from my script with py2app doesn't work on newer versions of OS X. I was told that this was because the build was partially standalone, meaning it requires my version of wxPython, but doesn't include it. How can I make it fully standalone (where my version of wxPython is included), or not standalone, where it uses whatever version of wxPython the host has installed? Which would be preferable, and how can I check that it has worked if I only have one mac with one version of wxPython? | true | 14,563,591 | 1.2 | 0 | 0 | 2 | Make sure you are using the latest py2app, it looks like they've resolved some issues lately related to semi-standalone, perhaps that may affect your build too.
Use the Python from Python.org, not Apple's python installed with the OS.
Don't use the --semi-standalone flag or options like it in the setup script.
That should be all there is to it. Last I checked creating standalone applications was the default when using the Python.org Python, and it by default should be copying in the other packages (including wx) that your application imports as well. You can look inside the generated application bundle to see exactly what it is and isn't including and you can then adjust your setup script as needed. | 0 | 684 | 0 | 2 | 2013-01-28T13:55:00.000 | python,wxpython,wxwidgets,py2app | Toggling py2app standalone? | 0 | 1 | 1 | 14,571,464 | 1 |
0 | 0 | I have a Gtk IconView. Actually, selected items are draw with a different background color (this is the normal behavior). However, I'd like to be able to distinguish between "selected" and "active" items, by using a different background color for the "active" item. How can I achieve that? | false | 14,612,802 | 0 | 0 | 0 | 0 | Are you using a theme? Check the panel.rc file and look for bg[ACTIVE]. Change that value and the button should change colour | 0 | 127 | 0 | 0 | 2013-01-30T20:13:00.000 | python,gtk | How to distinguish active and selected item in Gtk IconView? | 0 | 1 | 1 | 14,612,976 | 1 |
0 | 0 | I'm writing a game with two processes. One for rendering with OpenGL. The other is for Collision detection. This is so I can use more than a single core.
However I can't use any pygame surfaces without the display open. So I can't use bitmasks to do pixel perfect collision or any other collision for that matter.
I've tried to simply open another window just to see if I can the Surfaces to work but I can't open a second pygame window without getting an OpenGL function error.
You can open two non-OpenGL windows with pygame in two separate processes but I'm using OpenGL.
I figured there might be somewhere I can insert a pointer to the display to get the surfaces to stop saying Dead Display. Some kind of SDL variable I can manipulate in the second process to say "its not Dead its here". Or some other way to use the pixel perfect collision.
I'm open to pixel perfect alternatives that don't use pygame. | false | 14,643,579 | 0 | 0 | 0 | 0 | I'm going to use pymunk. The python port of Chipmunk.
I did a silly experiment with it little over a year ago when I first started programming. It was pretty easy. I just totally forgot about it.
I couldn't get pybox2d to work in any python version. | 0 | 141 | 0 | 0 | 2013-02-01T09:52:00.000 | python,opengl,pygame | Using pygames Collision module without initializing display | 0 | 1 | 2 | 14,807,386 | 1 |
0 | 0 | Is there a way to program a function that takes user input without requesting it? For example, during a game of tic-tac-toe, the user could press "Q" at any time and the program would close? | true | 14,651,989 | 1.2 | 0 | 0 | 1 | There are a few ways to do this, and they are all different.
If your game is a terminal application using curses, you would catch the q when you call getch(), and then raise SystemExit or simply break out of your while loop that many curses applications use.
Using tkinter or another GUI library, you would bind a key press event to your Frame widget that holds the tic-tac-toe board. | 0 | 362 | 0 | 1 | 2013-02-01T17:41:00.000 | python,input | Python 3.2 Passive User Input | 0 | 1 | 2 | 14,652,103 | 1 |
0 | 0 | I am using QT4 (4.2.1) with python 2.4 on CentOS.
I assigned QAction with shortcuts to my menu and disable/enable them accordingly. I have event handlers assigned to the triggered event for the actions. Everything works as expected except that the shortcuts trigger the events for disabled actions. For example, I have a Delete QAction with Del shortcut. I see the disabled Delete menu option but if I hit the Del key my triggered event handler gets called. This is kind of odd...
Is this by design or I am doing something wrong?
As a workaround I am now checking QAction isEnabled() in each action event handler but is there a way to not get triggered events for disabled actions?
Thank you very much for your help,
Leo | true | 14,653,860 | 1.2 | 0 | 0 | 0 | This behaves fine with Qt 4.8.5, and as far as I can tell from the source it should work with versions as old as Qt 4.5.
Try upgrading Qt to a reasonably recent version, or at least try your code on a more modern version. | 0 | 199 | 0 | 0 | 2013-02-01T19:46:00.000 | python,qt,qt4 | Shortcuts trigger events for disabled QActions | 0 | 1 | 1 | 14,654,391 | 1 |
0 | 0 | In python I want to simulate a joystick that when used, to give values between -63 and +63 let's say. When the value it's positive, I want to press the "w" key and "s" key when negative.
I am not having problems receiving the values, but to transform these analog values into digital key presses. Does anyone has any idea how to do it (code can be in any language, I just need an general idea). | true | 14,672,039 | 1.2 | 0 | 0 | 1 | Use PostMessage with the WM_CHAR command (if you're using Windows - you didn't say). | 0 | 118 | 0 | 0 | 2013-02-03T11:36:00.000 | python,keypress,joystick,analog-digital-converter | Transforming analog keypresses to digital | 0 | 1 | 1 | 14,709,657 | 1 |
0 | 0 | I have developed the python script for checking out a source code from repository and build it using visual studio.When i run the script,a GUI opens(developed using wxPython) which shows a button,clicking on which does the checkout and build.I would want to show a progress bar showing the process running when i click on the button and a success message after the script finishes it's work.Please help me out.
Thanks in advance. | true | 14,681,697 | 1.2 | 0 | 0 | 0 | You probably won't be able to get an accurate progress unless your build scripts are generating some progress information in the output that you can parse and represent in your GUI. Either way you will probably want to use wx.ProgressDialog or use a wx.Gauge in your main panel or something like that. Both wx.ProgressDialog and wx.Gauge can be used in a mode that shows actual values (a percentage complete) or an 'indeterminate' mode that represents that something is happening but there isn't any way to tell how far in the process it is. | 1 | 400 | 0 | 0 | 2013-02-04T06:52:00.000 | python-2.7,wxpython | Show progress bar when running a script | 0 | 1 | 1 | 14,692,494 | 1 |
0 | 0 | I have an application developed in Python using PyQt4, In which i used QTableView to display a reports.
when i open one report window with QTableView it shows the result properly.
If i open another report window with QTableView it shows the result properly.
Now both the windows are displaying the data in there QTableViews.
Now the issue is, When i select the 1st report window the data in it is disappearing.
Can anyone tell me exactly whats wrong i am doing. | true | 14,682,935 | 1.2 | 0 | 0 | 0 | Check if you are using same instance of QtSql.QSqlDatabase for all the views you create. | 0 | 91 | 0 | 1 | 2013-02-04T08:29:00.000 | python,pyqt4,qtableview | QTableView data disapears by opening another QTableView | 0 | 1 | 1 | 16,030,744 | 1 |
0 | 0 | I am using Tkinter with Python 2.6 and 2.7 for programming graphic user interfaces.
These User Interfaces contain dialogs for opening files and saving data from the tkFileDialog module. I would like to adapt the dialogs and add some further entry widgets e.g. for letting the user leave comments.
Is there any way for doing so?
It seems that the file dialogs are taken directly from the operating system. In Tkinter they are derived from the Dialog class in the tkCommonDialog module and call the tk.call("tk_getSaveFile") method of a frame widget (in this case for saving data).
I could not find out where this method is defined. | false | 14,686,543 | 0.099668 | 0 | 0 | 1 | I had to get rid of the canvasx/y statements. That line now simply reads set item [$data(canvas) find closest $x $y], which works well. $data(canvas) canvasx $x for its own works well but not in connection with find closest, neither if it is written in two lines. | 0 | 1,084 | 0 | 4 | 2013-02-04T12:12:00.000 | python,tkinter,filedialog | Python Tkinter: Adding widgets to file dialogs | 0 | 1 | 2 | 14,822,605 | 1 |
0 | 0 | I'm currently working on a small game using pygame.
Right now I render images the standard way, by loading them and then blitting them to my main surface. This is great, if I want to work with an individual image size. Yet, I'd like to take in any NxN image and use it at an MxM resolution. Is there a technique for this that doesn't use surfarray and numeric? Something that already exists in pygame? If not, do you think it would be expensive to compute this?
I'd like to stretch the image. So, upscale or downscale the image. Sorry I wasn't clearer. | true | 14,692,367 | 1.2 | 0 | 0 | 1 | There is no single command to do this. You will first have to change the size using pygame.transform.scale, then make a rect of the same size, and set its place, and finally blit. It would probably be wisest to do this in a definition. | 0 | 128 | 0 | 0 | 2013-02-04T17:45:00.000 | python,pygame | Rendering image independent of size? | 0 | 1 | 1 | 14,694,352 | 1 |
0 | 0 | I have seen a similar question on this site but not answered correctly for my requirements. I am reasonably familiar with py2exe.
I'd like to create a program (in python and py2exe) that I can distribute to my customers which would enable them to add their own data (not code, just numbers) and redistribute as a new/amended exe for further distribution (as a single file, so my code + data). I understand this can be done with more than one file.
Is this conceptually possible without my customers installing python? I guess I'm asking how to perform the 'bundlefiles' option?
Many thanks | false | 14,692,822 | 0.197375 | 0 | 0 | 1 | I think it is possible. I'm not sure how py2exe works, but I know how pyinstaller does and since both does the same it should work similiar.
Namely, one-file flag doesn't really create one file. It looks like that for end user, but when user run app, it unpacks itself and files are stored somewhere physically. You could try to edit some source file (ie numbers.py, or data.py) and pack it again with changed data.
I know it's not the best explanation, you have to think further on your own. I'm just showing you the possible way. | 1 | 167 | 0 | 3 | 2013-02-04T18:11:00.000 | python,py2exe | compile py2exe from executable | 0 | 1 | 1 | 14,693,751 | 1 |
0 | 0 | I am creating a wx.Frame with a GLCanvas. On some platforms, setting the WX_GL_DEPTH_SIZE attribute of the canvas to 32 works fine. On another platform, I just get a blank frame (the GLCanvas doesn't render) unless I reduce the depth size to 16. Is there an easy way in the calling code to determine the allowable values for the depth size? | false | 14,715,739 | 0.099668 | 0 | 0 | 1 | Are you running Linux? Perhaps you could get that information from the table of display modes that glxinfo -t outputs. | 0 | 239 | 0 | 1 | 2013-02-05T19:50:00.000 | python,wxpython,pyopengl | How can I determine the max allowable WX_GL_DEPTH_SIZE for a wx GLCanvas? | 0 | 1 | 2 | 14,971,097 | 1 |
0 | 0 | I'm creating a simple application through glade, and I want to be able to set the color displayed in the color selection dialog. I found the set_current_color function, however, it requires a gdk.Color object.
Trying to import gtk.gdk.Color fails (actually, just importing gtk fails). Is there another method I can use to create a color object? | false | 14,881,732 | 0 | 0 | 0 | 0 | It turned out to be an issue of mixing GTK2 and GTK3. gi.repository.Gtk has the Color constructor. | 0 | 125 | 0 | 0 | 2013-02-14T18:36:00.000 | python,gtk,pygtk,gdk | pygtk issue - unable to create gdk.Color object | 0 | 1 | 1 | 14,906,082 | 1 |
0 | 0 | I am trying to find a way to test my C code using python scripts. So far my findings are
1) with Ctypes, I can easily load the so and call the function directly from python. Plus, everything happens at run-time, so no extra compiling/wrapping stuff.
2) However, re-writing every types in python is tedious and error prone, especially for complex data types. And whenever the definitions change, I will have to update the definition in python scripts.
I am wondering since Swig can export datatypes automatically, is it possible to mix Swig and Ctypes together? i.e. use Swig to export datatypes, which can be used to call functions through Ctypes.
p.s I am not sure whether Cython suits better, but we don't have Cython in the environment. | false | 14,887,374 | 0 | 0 | 0 | 0 | I ended up using Swig with dynamic linking to the so library generated by the C code. In this way, I only have to include the header files in the swig interface file to tell swig what functions/datatypes to expose. Another advantage of this approach is that I can write testing helper functions in C and easily expose those as well. | 0 | 321 | 0 | 0 | 2013-02-15T02:09:00.000 | python,c,swig,ctypes | Python & C: Is it possible to mix Ctypes and Swig together? | 0 | 1 | 1 | 14,943,730 | 1 |
0 | 0 | I've been working on a very simple python/tkinter script (a .pyw file) and I'd like to change it's application icon (the 'file' icon shown at the explorer window and the start/all programs window, for example - not the 'file type' icon nor the main window of the app icon) and the taskbar icon (the icon shown at the taskbar when the application is minimized). Is it possible to change them or is it something only doable when you effectively install an application through an .exe?
This little app is supposed to run on Windows XP / 7 machines only and it's in Python 2.7.3.
Thanks in advance! | false | 14,900,510 | 0 | 0 | 0 | 0 | Create an single file exe using PyInstaller and use Inno Setup to build the windows installer package. Inno Setup will do the icon stuff for you. | 0 | 35,930 | 0 | 15 | 2013-02-15T17:53:00.000 | python,tkinter | Changing the application and taskbar icon - Python/Tkinter | 0 | 2 | 7 | 42,867,640 | 1 |
0 | 0 | I've been working on a very simple python/tkinter script (a .pyw file) and I'd like to change it's application icon (the 'file' icon shown at the explorer window and the start/all programs window, for example - not the 'file type' icon nor the main window of the app icon) and the taskbar icon (the icon shown at the taskbar when the application is minimized). Is it possible to change them or is it something only doable when you effectively install an application through an .exe?
This little app is supposed to run on Windows XP / 7 machines only and it's in Python 2.7.3.
Thanks in advance! | false | 14,900,510 | 0 | 0 | 0 | 0 | add
--icon=iconname.ico
to the pyinstaller command in the prompt
eg>> pyinstaller --windowed --add-data "pics/myicon.ico;pics" --add-data "pics/*.png;pics" --icon=pics/myicon.ico -d bootloader myscript.py
this will show your icon on the windows taskbar instead of the default python pkg icon | 0 | 35,930 | 0 | 15 | 2013-02-15T17:53:00.000 | python,tkinter | Changing the application and taskbar icon - Python/Tkinter | 0 | 2 | 7 | 72,111,647 | 1 |
0 | 0 | How can I tell a Tkinter window where to open, based on screen dimensions? I would like it to open in the middle. | false | 14,910,858 | 0.066568 | 0 | 0 | 2 | root.geometry('520x400+350+200')
Explanation: ('width x height + X coordinate + Y coordinate') | 0 | 110,461 | 0 | 67 | 2013-02-16T13:30:00.000 | python,python-2.7,tkinter | How to specify where a Tkinter window opens? | 0 | 1 | 6 | 55,293,163 | 1 |
0 | 0 | If there are lets say 4 buttons, all with the same Click event, how can I find out which button was pressed?
if the event looks like this def Button_Click(self, sender, e): I'm sure I can compare sender to my buttons somehow. But how? | true | 14,959,093 | 1.2 | 0 | 0 | 1 | Well, I've never used IronPython so I don't know how much help this will be, but what I usually do when trying to figure out these things in regular python is to print type(sender) , print sender and print dir(sender) to console(or output to a file if you don't have a console available).
This should help you figure out what exactly is the "sender" parameter. In the simplest case it could be the button itself so a simple == will work to know which button it was. Or it could have a method/property that gets you the button object. In which case, dir(sender) might contain an obvious one, or if not, google the class name gotten from type(sender) and see if you can find any docs. | 0 | 901 | 0 | 0 | 2013-02-19T13:47:00.000 | python,.net,ironpython | event handling iron python | 0 | 1 | 1 | 14,959,257 | 1 |
0 | 0 | mi problem is this. I´ve already created a program with tkinter, but I want to run it twice in the same window, one in each side of the window. How can I do that??
The idea is to be able to compare the data from both programs so I want them to work separated.
Many thanks.
PD: I cannot post an image for you because of my reputation, sorry :( | false | 14,994,651 | 0.379949 | 0 | 0 | 2 | Ultimately, what you need to do is put all of the logic behind creating and using a single workspace on a single Frame object. Then you just need to create 2 Frames side-by-side -- Each one holding a "workspace". | 0 | 100 | 0 | 0 | 2013-02-21T04:39:00.000 | python,programming-languages,tkinter | How can I create 2 workspaces in tkinter | 0 | 1 | 1 | 14,994,664 | 1 |
0 | 0 | I have a Qt application written in PySide (Qt Python binding). This application has a GUI thread and many different QThreads that are in charge of performing some heavy lifting - some rather long tasks. As such long task sometimes gets stuck (usually because it is waiting for a server response), the application sometimes freezes.
I was therefore wondering if it is safe to call QCoreApplication.processEvents() "manually" every second or so, so that the GUI event queue is cleared (processed)? Is that a good idea at all? | false | 15,014,932 | 0 | 0 | 0 | 0 | A couple of hints people might find useful:
A. You need to beware of the following:
Every so often the threads want to send stuff back to the main thread. So they post an event and call processEvents
If the code runs from the event also calls processEvents then instead of returning to the next statement, python can instead dispatch a worker thread again and that can then repeat this process.
The net result of this can be hundreds or thousands of nested processEvent statements which can then result in a recursion level exceeded error message.
Moral - if you are running a multi-threaded application do NOT call processEvents in any code initiated by a thread which runs in the main thread.
B. You need to be aware that CPython has a Global Interpreter Lock (GIL) that limits threads so that only one can run at any one time and the way that Python decides which threads to run is counter-intuitive. Running process events from a worker thread does not seem to do what it says on the can, and CPU time is not allocated to the main thread or to Python internal threads. I am still experimenting, but it seems that putting worker threads to sleep for a few miliseconds allows other threads to get a look in. | 0 | 1,998 | 0 | 2 | 2013-02-22T00:37:00.000 | python,qt,events,pyqt,pyside | Is calling QCoreApplications.processEvents() on a set interval safe? | 0 | 1 | 2 | 42,914,476 | 1 |
0 | 0 | I have tried using pythonw and this only works if I drop and drag the file onto it. I remember reading somewhere there is a way to keep this from happening in the code but I can't find it. Thanks in advance. | false | 15,018,411 | 0.379949 | 0 | 0 | 2 | To run it with pythonw.exe just give your file a .pyw extension. | 0 | 57 | 0 | 0 | 2013-02-22T06:44:00.000 | python,python-2.7,wxpython | How do I keep shell or IDLE shell from opening when running wxPython | 0 | 1 | 1 | 15,018,504 | 1 |
0 | 1 | I have created a 10 by 10 game board. It is a 2D list, with another list of 2 inside. I used
board = [[['O', 'O']] * 10 for x in range(1, 11)]. So it will produce something like
['O', 'O'] ['O', 'O']...
['O', 'O'] ['O', 'O']...
Later on I want to set a single cell to have 'C' I use board.gameBoard[animal.y][animal.x][0] = 'C'
board being the class the gameBoard is in, and animal is a game piece, x & y are just ints. Some times it will work and the specified cell will become ['C', 'O'], other times it will fill the entire row with ['C', 'O']['C', 'O']['C', 'O']['C', 'O']
Does anyone know why that might be happening? | false | 15,036,694 | 0 | 0 | 0 | 0 | Your board is getting multiple references to the same array.
You need to replace the * 10 with another list comprehension. | 0 | 168 | 0 | 1 | 2013-02-23T03:25:00.000 | python,list | 2D Python list will have random results | 0 | 1 | 3 | 15,036,718 | 1 |
0 | 0 | How to run multiple processes in python without multithreading? For example consider the following problem:-
We have to make a Gui,which has a start button which starts a function(say, prints all integers) and there is a stop button, such that clicking it stops the function.
How to do this in Tkinter? | false | 15,057,789 | 0 | 0 | 0 | 0 | Did you try to used multiprocessing module? Seems to be the one you're looking for. | 1 | 7,177 | 0 | 4 | 2013-02-24T23:08:00.000 | python,tkinter,multiprocessing | Multiprocessing in Python tkinter | 0 | 1 | 2 | 15,057,824 | 1 |
0 | 0 | Im struggling opening a powerpoint presentation via python.
I have a program in educational program in pyqt and i need to open up a powerpoint presentation(in powerpoint viewer mode) when i click a push button.
I tried using pywin32 and such but ive had no luck :( | false | 15,058,771 | 0 | 0 | 0 | 0 | Import the os module, then use os.system("powerpoint.exe filename") | 0 | 3,049 | 0 | 2 | 2013-02-25T01:20:00.000 | python,pyqt,powerpoint | How to open a powerpoint presentation via python? | 0 | 1 | 1 | 15,058,874 | 1 |
0 | 0 | I'm making a simple game, whereby I want my characters quite customizable. I want my characters to be able to be fully edited in colours, for example, if a player wants their character to have cyan skin, they just put into the sliders, or what I choose to use, "0,255,255", or purple "255,0,255", or something random "25,125, 156", and have their character be that colour. I haven't even started creating the game, but I've got the basis down and I know exactly what I must do for pretty much every EXCEPT this.
I done a search in Google, and it turns out, I need numerical python for this? Well this is a whole new package, and in order for the average player to play, I must change it to EXE form... (or have python, pygame and numerical python installed onto their PC, which will be a problem if they have a later version...). Now, it's already getting complex with just pygame, but with numerical python as well, is there even a tutorial on how to do this?
Any suggestions? Thanks! | false | 15,076,133 | 0 | 0 | 0 | 0 | I assume by image you mean pygame.Surface. You have several options:
pygame.Surface.set_at(...)
Use a palettized surface. Then change the palette. Based on your use case, this is actually probably what I'd suggest.
Use the pygame.PixelArray PyGame module. I don't think it requires NumPy.
Just use NumPy. It's really not that huge of a requirement; lots of projects require it and it's simple to set up. You get access to the powerful pygame.surfarray module | 1 | 2,070 | 0 | 0 | 2013-02-25T20:44:00.000 | python,image,colors,pygame,numerical | PYGAME - Edit colours of an image (makes white red at 255,0,0) without numerical python? | 0 | 1 | 2 | 28,798,012 | 1 |
0 | 0 | Is there anyway the pyc file can be extracted from an Application bundle? I'm referring to an application bundle that was created by using py2app on python code. | false | 15,093,865 | 0.197375 | 0 | 0 | 1 | The pyc files are stored in a zipfile in the Resources folder. The name of the zip file depends on the Python version, for 2.7 it is .app/Contents/Resources/python2.7/site-packages.zip.
That zip file is a regular zipfile that can be manipulated with the usual tools. | 1 | 171 | 0 | 0 | 2013-02-26T16:10:00.000 | python,macos,py2app | extract pyc from Application bundle | 0 | 1 | 1 | 15,098,915 | 1 |
0 | 0 | I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards.
Would it be bad to store the processing info as:
Card_79x123_53_53.png
Upon getting the filename from a file dialog, I would split the underscores to get the following info:
ObjectType : matched to list
(w,h)
Number of objects expected (in case there's tailing empty space)
Extra info (in this case the location of the face-down texture relative to N above)
and the dimensions of the image provide the rest, of course.
ANY error in processing would of course be raised and the attempt to load textures would be rejected.
Is there a reason why this is a bad idea or should I keep toying with it? | false | 15,104,090 | 0 | 0 | 0 | 0 | Is there a reason why this is a bad idea or should I keep toying with it?
This is essentially like encoding file type by file extension. The only bad thing about encoding file metadata in the filename is it's quite limited in space. You can encode much richer metadata if you used proper PNG metadata field or in a separate file. Encoding metadata in the file name is hard to extend with new fields in new version, with optional fields, etc.
For example, you might find out that you want miscellaneous sprite sheet where each frame has different size, and so you need to encode the position, size, class name, and serial number for each individual frame.
It's fine as long as you don't expect to want to encode many other metadata in the future. | 0 | 65 | 0 | 0 | 2013-02-27T04:13:00.000 | python,png | Is it a bad idea to use a PNG image's filename to store the info on how to process it? | 0 | 2 | 2 | 15,104,289 | 1 |
0 | 0 | I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards.
Would it be bad to store the processing info as:
Card_79x123_53_53.png
Upon getting the filename from a file dialog, I would split the underscores to get the following info:
ObjectType : matched to list
(w,h)
Number of objects expected (in case there's tailing empty space)
Extra info (in this case the location of the face-down texture relative to N above)
and the dimensions of the image provide the rest, of course.
ANY error in processing would of course be raised and the attempt to load textures would be rejected.
Is there a reason why this is a bad idea or should I keep toying with it? | true | 15,104,090 | 1.2 | 0 | 0 | 0 | Probably it would be better to ask user about how to process image explicitly either by adding extra controls into file dialog, or by showing another dialog after file dialog is submitted. In this case information taken from file name could be used as hints to preliminary fill these extra controls with values, but user will have a chance to correct what is wrong and fill what is missing. | 0 | 65 | 0 | 0 | 2013-02-27T04:13:00.000 | python,png | Is it a bad idea to use a PNG image's filename to store the info on how to process it? | 0 | 2 | 2 | 15,104,140 | 1 |
0 | 0 | I wanted to create a file copy program in which progress bar indicates progress. Now if I started n copy/paste operations, that many progress bars should be displayed like windows 8 does.
The program should be like one window, say "SHOW", is displaying QProgressbar for copy/paste of 1st operation. When 2 copy/paste will start before 1st one finishes, the 2nd QProgressbar will be added in SHOW and hence there will be 2 progressbars in SHOW. | false | 15,119,751 | 0 | 0 | 0 | 0 | Well create a layout (a vertical layout i suppose) and then create as many QProgressbar you need and add them to your layout with addWidget and that's it.
If you need scrolling, try using a QScrollArea. | 0 | 104 | 0 | 0 | 2013-02-27T18:40:00.000 | python,multithreading,pyqt | How to add new QProgressbar to an existing window? | 0 | 1 | 1 | 15,119,949 | 1 |
0 | 0 | I am using Python 3 with gobject introspection for Gtk. How can I have more than one toggle button linked together so they behave similar to tabs or radiobuttons - e.g. one is selected by default, and when another is clicked the previously active one is de-selected.
I have tried using set_sensetive, but that greys out the widget that it is applied on. | true | 15,120,746 | 1.2 | 0 | 0 | 3 | Use set_active() (or props.active). Alternatively, you can create some Gtk.RadioButton widgets and set draw_indicator property to False. In the latter case you can create radio groups in normal way, without custom handling. | 0 | 1,466 | 0 | 3 | 2013-02-27T19:32:00.000 | python,button,gtk,radio-button,toggle | How can I link a set of toggle buttons like radio buttons? | 0 | 2 | 3 | 15,123,955 | 1 |
0 | 0 | I am using Python 3 with gobject introspection for Gtk. How can I have more than one toggle button linked together so they behave similar to tabs or radiobuttons - e.g. one is selected by default, and when another is clicked the previously active one is de-selected.
I have tried using set_sensetive, but that greys out the widget that it is applied on. | false | 15,120,746 | 0.066568 | 0 | 0 | 1 | You listen to the toggle signals on the toggle button then call set_active() on the other ones. You need to block the toggled signals while calling set_active()so that you don't get into a loop. | 0 | 1,466 | 0 | 3 | 2013-02-27T19:32:00.000 | python,button,gtk,radio-button,toggle | How can I link a set of toggle buttons like radio buttons? | 0 | 2 | 3 | 15,135,787 | 1 |
0 | 0 | I am making a GUI in wxpython.
I want to place images next to radio buttons.
How should i do that in wxpython? | false | 15,128,404 | 0 | 0 | 0 | 0 | I'm not sure what you mean. Are you wanting images instead of the actual radio button itself? That is not supported. If you want an image in addition to the radio button, then just use a group of horizontal box sizers or one of the grid sizers. Add the image and then the radio button. And you're done! | 0 | 348 | 0 | 0 | 2013-02-28T05:51:00.000 | wxpython | Adding images next to radio buttons in wxpython | 0 | 2 | 3 | 15,138,009 | 1 |
0 | 0 | I am making a GUI in wxpython.
I want to place images next to radio buttons.
How should i do that in wxpython? | false | 15,128,404 | 0.066568 | 0 | 0 | 1 | I suggest using wx.ToggleButton with bitmap labels if you are using 2.9, or one of the bitmap toggle button classes in wx.lib.buttons if you are still on 2.8. You can then implement the "radio button" functionality yourself by untoggling all other buttons in the group when one of them is toggled. Using the bitmap itself as the radio button will look nicer and will save space. | 0 | 348 | 0 | 0 | 2013-02-28T05:51:00.000 | wxpython | Adding images next to radio buttons in wxpython | 0 | 2 | 3 | 15,145,613 | 1 |
0 | 0 | I have application with QtGui.QSystemTrayIcon and a Qmenu in it. Is there a way to disable and enable it.
I want this to disable when my application is launching, so that user have no option to access the menu items. | false | 15,131,690 | 0 | 0 | 0 | 0 | There are .show() and .hide() methods and a .visible property that allows to show or hide a QSystemTrayIcon.
Is that what you were looking for? | 0 | 798 | 0 | 0 | 2013-02-28T09:18:00.000 | python,pyqt4,system-tray | Disabling System Tray icon in pyqt | 0 | 1 | 1 | 15,135,837 | 1 |
0 | 0 | I currently have a wxPanel that I draw lines, text etc on to in response to paint events by using a device context from wx.PaintDC. However, my drawing can exceed the size of the panel and it continues off the visible screen. The only way to see more of the drawing is to expand the application window, which is impractical and still may not allow the full drawing to be seen in the case of very large drawings. Ideally, I want to be able to scroll the drawing so that the application window does not need to be resized and large drawings can be seen.
Looking around, it seems that I may want to use a wxScrolledPanel instead of a wxPanel. However, i've had no success with using this - would using a wxScrolledPanel only work when using controls (e.g. buttons, text fields) rather than painting on the device context?
What is the appropriate way to scroll a panel that has been drawn on? | true | 15,143,323 | 1.2 | 0 | 0 | 2 | It should work with a ScrolledPanel but if you are not going to have other widgets on the panel it is probably not the right answer since it depends on having a sizer to set the virtual size.
Try using a wx.ScrolledWindow instead, and see its sample in the demo for some code. Basically you just need to set the virtual size of the window and it will take care of the scrollbars and scrolling for you. You will also need to call PrepareDC in your paint event handler so it will offset the drawing to match the scrolled viewport origin. | 0 | 1,073 | 0 | 0 | 2013-02-28T18:48:00.000 | wxpython,paint,gdi | Scrolling a painted frame in wxPython | 0 | 1 | 2 | 15,146,608 | 1 |
0 | 0 | I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it? | false | 15,171,378 | 0.099668 | 0 | 0 | 1 | What methods are you using to draw the images? It's hard to answer this question without that.
If you aren't already doing this, you could use a class to hold data about your image, such as position and geometry. | 0 | 1,791 | 0 | 0 | 2013-03-02T06:07:00.000 | python,image,drag-and-drop,pygame | How to get image position in Pygame | 0 | 2 | 2 | 15,173,810 | 1 |
0 | 0 | I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it? | false | 15,171,378 | 0.099668 | 0 | 0 | 1 | If you derive your classes from pygame.sprite.Sprite , you can get the position by guy.rect. Depending on if you want center, or toplef, or the full rect:
guy.rect.topleft or guy.rect.center or guy.rect | 0 | 1,791 | 0 | 0 | 2013-03-02T06:07:00.000 | python,image,drag-and-drop,pygame | How to get image position in Pygame | 0 | 2 | 2 | 15,177,879 | 1 |
0 | 0 | In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes? | false | 15,180,320 | 0.049958 | 0 | 0 | 1 | You can change a Widget property by using the Gtk.Widget.set_property(property, value) method. property should be a string. | 0 | 3,329 | 0 | 3 | 2013-03-02T22:44:00.000 | python,styles,gtk,pygtk,pygobject | Editing GtkWidget attributes/properties | 0 | 2 | 4 | 15,180,684 | 1 |
0 | 0 | In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes? | true | 15,180,320 | 1.2 | 0 | 0 | 4 | There are three ways to change properties:
As in zheoffec's answer, use the set_property() function (or set_style_property() for style properties.) This function is actually not necessary in Python, but it is there for completeness because it is part of the C API.
Use the props attribute. Any property that you find in the documentation can be accessed through this attribute. For example, btn1.props.label = 'StackOverflow' and btn1.props.use_underline = False.
Use the getter and setter functions as frb suggests. These are also only present because they are part of the C API, but some people prefer them over the props attribute. Also, there is no guarantee that any particular property will have getter and setter functions! Usually in a well-designed C API they will be there, but it is not required.
For style properties, I believe the only option is #1. For "attributes", well, these are simply Python attributes. To access the allocation attribute, use btn1.allocation. | 0 | 3,329 | 0 | 3 | 2013-03-02T22:44:00.000 | python,styles,gtk,pygtk,pygobject | Editing GtkWidget attributes/properties | 0 | 2 | 4 | 15,184,441 | 1 |
0 | 0 | I have both text and image in QLabel, so setPixmap won't satisfy my requirement.
As far as I know, QLabel can load image from file by setting HTML label <img src="path_to_file" />. But how can I load image from memory(e.g. QImage)? Because some images are frequently used, it may have performance problem loading the same image from file every time. | false | 15,195,880 | 0 | 0 | 0 | 0 | You have two choices:
use two labels, one with the text and one with the image.
use a QPainter to draw the text over the image. | 0 | 1,496 | 0 | 0 | 2013-03-04T06:34:00.000 | python,qt,python-3.x,pyqt | How to insert QImage(or sth like that) into QLabel? | 0 | 2 | 3 | 15,195,943 | 1 |
0 | 0 | I have both text and image in QLabel, so setPixmap won't satisfy my requirement.
As far as I know, QLabel can load image from file by setting HTML label <img src="path_to_file" />. But how can I load image from memory(e.g. QImage)? Because some images are frequently used, it may have performance problem loading the same image from file every time. | false | 15,195,880 | 0 | 0 | 0 | 0 | You can also set stylesheet for your QLabel as:-
QLabel{
background-image: url(/images/button.png); | 0 | 1,496 | 0 | 0 | 2013-03-04T06:34:00.000 | python,qt,python-3.x,pyqt | How to insert QImage(or sth like that) into QLabel? | 0 | 2 | 3 | 15,198,050 | 1 |
0 | 0 | I'm creating a program in python, and use GTK for part of it.
Whenever GTK opens, it causes the whole program to stop responding, and not move on to the next process. Ideally, i would like it if the gtk window opened independently to the rest of the program, since the GTK window is just to display information, and the functionality is text based
Is there any way to continue executing the python program, after the GTK window opened. I can't find anything in the pygtk manuals
Any help would be great, thansks | false | 15,271,870 | 0 | 0 | 0 | 0 | If your program has a Gtk UI then the program is supposed to be driven by the GTK main loop. You may be able to run a gtk main loop in a secondary thread, but that it not really a supported configuration and you may run into many more problems | 0 | 159 | 1 | 0 | 2013-03-07T12:58:00.000 | python,gtk | gtk allow background processes | 0 | 1 | 1 | 15,276,223 | 1 |
0 | 0 | I am having some problems with a app we are making with wxWidget/wxPython and PyInstaller.
We have compiled the app into a single exe for windows but:
1) On some machines it will not launch at all. It doesn't generate a error or anything in the app logs. It just stops almost immediately.
2) On some machines it will launch fine from cmd but not from explorer. again, same behavior. It just stops almost immediately. I don't even see it pop up in the process explorer.
3) On some machines it works just fine.
Are there any tips on how I can figure out what is going wrong? Is there a way to launch a exe with a debugger? | true | 15,298,618 | 1.2 | 0 | 0 | 1 | There are a few things you may want to look into:
Did you compile it as "one file"? I have heard that one exe may be blocked by some antivirus programs. It uses a few of hacks to get everything in one executable which may be considered malicious.
Did you compile it as Windows app (no console)? You may want to enable console and run it on machine where it does not run at all from console. That way you may see why it crashes. | 1 | 374 | 0 | 0 | 2013-03-08T16:24:00.000 | windows,wxpython,wxwidgets,pyinstaller | PyInstaller Created App WIll Launch from cmd but not from explorer | 0 | 1 | 1 | 15,678,526 | 1 |
0 | 0 | Are there any Python game libraries (Pygame, Pyglet, etc.) with support for RPython? Or game libraries specifically made for RPython? Or bindings for a game library for RPython? | false | 15,317,707 | 0 | 0 | 0 | 0 | RPython is not Python. They are different languages even though it just so happens that you can execute RPython code with a Python interpreter and get similar effects (much more slowly) to running the compiled RPython program. It is extremely unlikely for there to ever be any reasonable Python library (game library or any other kind) that also works in RPython. It would have to be specifically written for RPython, and if it worked in RPython it would be so inflexible when considered as a regular Python library that nobody would use it in that context.
If you want to program in a lower level compiled language with game libraries, use C# or Java. RPython is not a good competitor (in large part because it has very few libraries for anything, not even much of a standard library).
If you want to program in Python, use Python (possibly use the PyPy implementation of Python, which can be faster than the standard Python interpreter if it supports all the libraries you're using). RPython will not help you write Python code that goes faster.
If your goal is not to specifically produce a game, but rather to do some project in RPython because you want to learn RPython specifically, then that's a perfectly reasonable aim. But writing a game in will probably not be the most helpful project for learning to write RPython; you should probably consider writing some sort of interpreter instead, since that's what RPython is designed to do. | 0 | 255 | 0 | 1 | 2013-03-10T00:53:00.000 | python,game-engine,pypy,rpython | Game Library with Support for RPython | 0 | 1 | 2 | 15,564,865 | 1 |
1 | 0 | I will be in charge of teaching a small group of middle school students how to program phone applications. After much research I found that Python might be the best way to go.
I am a website development senior at my university, but I have not used Python before. I understand both ActionScript and Javascript and I think their logic might be beneficial for learning Python. For the web languages I am familiar with writing I use Sublime2, Dreamweaver, or Flash to code them.
So my questions are:
Which program do I use to code Python?
How do I use the code created in Python to work on Android phones? | false | 15,319,018 | 0 | 0 | 0 | 0 | Dr. python is a good ide/editor, but its simple to use. If your using linux, you can install it in the software center. I don't know how to install it on OSX/Windows | 0 | 91,831 | 0 | 28 | 2013-03-10T04:46:00.000 | android,python | How do I program an Android App with Python? | 0 | 1 | 5 | 27,331,662 | 1 |
0 | 0 | I have a bunch of objects interacting with each other. They all draw ovals that constitute representations of themselves on a Tkinter Canvas, and store the representation's Tkinter id as an attribute.
How can I make it so when I click one of the ovals, my program will print the other attributes of the object which that oval represents? | true | 15,344,185 | 1.2 | 0 | 0 | 1 | When you click on an item, you can get the canvas item id of the one that was clicked on. You would then use this information to look up the actual object. You can either iterate over all your objects looking for one with the given id, or you can keep a dictionary which maps ids to objects. Once you have the actual object, you can print the other attributes however you want. | 0 | 177 | 0 | 0 | 2013-03-11T16:55:00.000 | python,tkinter | Returning object information after clicking its representation in a Tkinter canvas | 0 | 1 | 1 | 15,344,805 | 1 |
0 | 0 | I am writing a python script(using python clang bindings) that parses C headers and extracts info about functions: name, return types, argument types.
I have no problem with extracting function name, but I can't find a way to convert a clang.cindex.Type to C type string. (e.g. clang.cindex.TypeKind.UINT to unsigned int)
Currently, as a temporary solution, i have a dictionary clang.cindex.TypeKind -> C type string and code to process pointers and const qualifiers, but I didn't found a way to extract structure names.
Is there a generic way to get C definition of clang.cindex.Type? If there isn't, how can I get C type string for clang.cindex.TypeKind.RECORD and clang.cindex.TypeKind.FUNCTIONPROTO types? | true | 15,388,961 | 1.2 | 0 | 0 | 2 | For RECORD, the function get_declaration() points to the declaration of the type (a union, enum, struct, or typedef); getting the spelling of the node returns its name. (Obviously, take care between differentiating the TYPEDEF_DECL vs. the underlying declaration kind.)
For FUNCTIONPROTO, you have to use a combination of get_result() and get_arguments(). | 0 | 1,599 | 0 | 4 | 2013-03-13T15:04:00.000 | python,clang,llvm-clang | Extract type string with Clang bindings | 0 | 1 | 1 | 18,359,608 | 1 |
0 | 0 | I have written a very simple script for my raspberry pi that loads an uncompressed WAV and plays it - however when I run the script as root (to be able to use GPIO and ServoBlaster), there is no sound output.
I have set the default audio device to a USB sound card, and this works - I have tested this using aplay fx.wav.
Running the pygame script without sudo, the sound plays fine.
What is going on here? | true | 15,405,082 | 1.2 | 1 | 0 | 1 | The issue was the sudo command changing the directory in which the script was being run - so running python with sudo -s or simply using an absolute path for the sound fixed it. | 0 | 1,087 | 0 | 0 | 2013-03-14T09:08:00.000 | python,audio,pygame,sudo,raspberry-pi | When running a pygame script as root, no sound is output? | 0 | 1 | 1 | 15,428,577 | 1 |
0 | 0 | So I have a lot of python scripts that I have written for my work but no one in my lab knows how to use Python so I wanted to be able to generate a simple Mac App where you can 'Browse' for a file on your computer and type in the name of the file that you want to save . . . everything else will be processed by the application for the python script I have generated.
Does anyone know if this is possible? I watched some tutorials on people generating applications in Xcode with Objective C but I don't want to have to learn a new language to reconstruct my Python scripts.
Thank you | true | 15,469,799 | 1.2 | 0 | 0 | 0 | Open Automator
Choose "Application"
Drag a "Run Shell Script" onto the workflow panel
Choose "/usr/bin/python" as the shell. Paste in your script, and select Pass Input: "to stdin"
Or, choose bash as the shell, and simply have the automator script run your Python script with Pass Input "as arguments" selected on the top right. You'll then use the contents of $@ as your arguments.
Save the application.
Done. You have a .app onto which files can be dragged. | 0 | 3,884 | 1 | 3 | 2013-03-18T04:31:00.000 | python,xcode,interface | Is it possible to create Python-based Application in Xcode or equivalent? | 0 | 1 | 3 | 15,469,982 | 1 |
0 | 0 | I have a game, written in Python, and I use Panda3d.
Now I want to have a possibility for restart, that is, I want to press a button with the result that the main is executed again, just as if the current instance of the game had never existed.
Is there a simple way to do this? | false | 15,486,091 | 0.291313 | 0 | 0 | 3 | Not really. Panda3D doesn't really make this abstraction, that's up to the application developer. It depends on the specific case what "restart" really means; do you want to close the existing window and then reopen a new one? If not, then that means that you have to keep many Panda3D objects in place and can't simply recreate the ShowBase instance. But do you then want to unload any models loaded into memory? Do you want to resend the geometry for your UI objects to the graphics card?
So, depending on your specific needs, you will have to unload and get rid of the objects that you need to restart and then recreate them. If you use an object oriented approach and structure your objects properly, this should be straightforward - ie, you implement an unload() on your Game object that unloads things specific to that game, and then let the references to that object go (causing it to be garbage collected), and create a new one. (Beware of circular references! If you have them, they may keep old instances of your objects in memory even when they have gone out of scope.) | 0 | 583 | 0 | 1 | 2013-03-18T20:17:00.000 | python,application-restart,panda3d | panda3d - how to restart a game | 0 | 1 | 2 | 15,522,504 | 1 |
0 | 0 | Do you have to have pygame installed to run pygame games? I have programmed a game in pygame on my Raspberry Pi (using the Adafruit WebIDE), and I don't want to have to run it on the Pi itself, so I am planning to use it on my Windows 8 box, and I don't have pygame installed on the Windows box. | false | 15,488,944 | -0.066568 | 0 | 0 | -1 | You cannot run a python program without python installed. However you could make the program an exe file by using a certain converter. Some converters are py2exe, pyinstaller, and cx_freeze. I personally recommend cx_freeze. If you use cx_freeze you must add the line import pygame._view to your source code due to a bug. | 1 | 4,043 | 0 | 1 | 2013-03-18T23:36:00.000 | python,pygame | Do you have to have pygame installed to run pygame games? | 0 | 2 | 3 | 15,625,491 | 1 |
Subsets and Splits