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 am building a file browser using Gtk.IconView in python. I am trying to find the path of an icon selected using " selection-changed" signal using gtk.IconView.get_path_at_pos(x,y).
The docs are mum on how to obtain the (x,y). How do I find them?
using python 2.7 and pygtk 2.24 | true | 22,940,269 | 1.2 | 0 | 0 | 1 | You don't use get_path_at_pos. It is meant for cases where you handle the button presses directly (which you should avoid unless you really have good reasons to do so).
Simply use gtk_icon_view_get_selected_items (C) or the pygtk equivalent iconview.get_selected_items() which gives you a list (in C a GList) of currently selected Gtk.TreePaths which is what you desire. | 0 | 84 | 0 | 0 | 2014-04-08T14:35:00.000 | python,gtk | Finding Mouse click position in IconView in GTK | 0 | 1 | 1 | 22,942,890 | 1 |
0 | 0 | Is there a way to have a ListCtrl cell span several columns? Or perhaps to able to append a panel / other element to a ListCtrl item that will contain the info I need? | true | 22,948,589 | 1.2 | 0 | 0 | 1 | No. The ListCtrl does not support that functionality. There is a pure Python list control widget called the UltimateListCtrl that allows you add any widget to a cell, although it doesn't appear to allow cell spanning either. I would still try this widget and see if it works for you. If it does not, you may be able to patch it yourself because it's written in Python or you could do a feature request for it to be added to the UltimateListCtrl on the wxPython mailing list and see if anyone takes you up on it.
You can do spanning in a wx.Grid widget if you wanted to go that route, although it's pretty limited when it comes to embedding other widgets. | 0 | 30 | 0 | 0 | 2014-04-08T21:30:00.000 | python-2.7,wxpython | Possible for ListCtrl Colspan, or similar functionality? | 0 | 1 | 1 | 22,968,522 | 1 |
0 | 0 | I have a QGLWidget in which openGL objects are created. I want to get better anti-aliasing than I have now by using glutInitDisplayMode(GLUT_DOUBLE | GLUT_MULTISAMPLE | GLUT_DEPTH).
How can I impliment this function (in python)? | true | 22,961,926 | 1.2 | 0 | 0 | 1 | Qt is an application framework that implements the GUI event loop. GLUT is an application, that implements the GUI event loop. There can be only one GUI event loop in a process. Hence Qt and GLUT can not be mixed.
Just configure QGLWidget with multisampling. Create a QGLFormat instance, call setSampleBuffers(true) on it, and pass it to the QGLWidget constructor. | 0 | 238 | 0 | 1 | 2014-04-09T12:03:00.000 | python,opengl,glut,antialiasing,qglwidget | How can I use glutInitDisplayMode() in a QGLWidget, so I can get anti-aliasing? | 0 | 1 | 1 | 22,969,282 | 1 |
0 | 0 | I am creating an application in Python that uses SQLite databases and wxPython. I want to implement it using MVC in some way. I am just curious about threading. Should I be doing this in any scenario that uses a GUI? Would this kind of application require it? | false | 22,999,993 | 0.049958 | 0 | 0 | 1 | You will use multithreading to perform parallel or background tasks that you don't want the main thread to wait, you don't want it to hang the GUI while it runs, or interfer with the user interactivity, or some other priority tasks.
Most applications today don't use multithreading or use very little of it. Even if they do use multi threads, its usually because of libraries the final programmer is using and isn't even aware that multithreading is happening there as he developed his application.
Even major softwares like AutoCAD use very little multithreading. It's not that its poorly made, but multithreading has very specific applications. For instance, it is pointless to allow user interaction while the project he wants to work on is still loading. A software designed to interact with a single user will hardly need it.
Where you can see multithreading fit a really important role is in servers, where a single application can attend requests from thousands of users without interfering with each other. In this scenario the easier way to make sure everyone is happy is by creating a new thread to each request. | 1 | 106 | 0 | 1 | 2014-04-10T22:08:00.000 | python,multithreading,model-view-controller,python-multithreading | When should I be considering using threading | 0 | 4 | 4 | 23,000,219 | 1 |
0 | 0 | I am creating an application in Python that uses SQLite databases and wxPython. I want to implement it using MVC in some way. I am just curious about threading. Should I be doing this in any scenario that uses a GUI? Would this kind of application require it? | false | 22,999,993 | 0.049958 | 0 | 0 | 1 | Actually, GUIs are typically single threaded implementations where a single thread (called UI thread) keeps polling for events and keeps executing them in the order they occur.
Regarding the main question, consider this scenario.
At the click of a button you want to do something time consuming that takes say 5-10 seconds or more. You have got 2 options.
Do that operation in the main UI thread itself. This will freeze the UI for that duration and user will not be able to interact with it.
Do that operation in a separate thread that would on completion just notify the main UI thread (in case UI thread needs to make any UI updates based on result of the operation). This option will not block the UI thread and user can continue to use the application.
However, there will be situations where you do not want user to be using the application while something happens. In such cases usually you can still use a separate thread but block the UI using some sort of overlay / progress indicator combination. | 1 | 106 | 0 | 1 | 2014-04-10T22:08:00.000 | python,multithreading,model-view-controller,python-multithreading | When should I be considering using threading | 0 | 4 | 4 | 23,000,279 | 1 |
0 | 0 | I am creating an application in Python that uses SQLite databases and wxPython. I want to implement it using MVC in some way. I am just curious about threading. Should I be doing this in any scenario that uses a GUI? Would this kind of application require it? | true | 22,999,993 | 1.2 | 0 | 0 | 0 | almost certainly you already are...
alot of wx is already driven by an asynchronous event loop ..
that said you should use wx.PubSub for communication within an MVC style wx Application, but it is unlikely that you will need to implement any kind of threading (you get it for free practically)
a few good places to python threading(locked by gil) use are:
serial communication
socket servers
a few places to use multiprocessing (still locked by gil but at least it sends it to different cores)
bitcoin miners
anything that requires massive amounts of data processing that can be parallelized
there are lots more places to use it, however most gui are already fairly asynchronously driven by events (not entirely true, but close enough), and sqlite3 queries definitely should be executed one at a time from the same thread(in fact sqlite breaks horribly if you try to write to it in two different threads)
this is likely all a gross oversimplification | 1 | 106 | 0 | 1 | 2014-04-10T22:08:00.000 | python,multithreading,model-view-controller,python-multithreading | When should I be considering using threading | 0 | 4 | 4 | 23,000,020 | 1 |
0 | 0 | I am creating an application in Python that uses SQLite databases and wxPython. I want to implement it using MVC in some way. I am just curious about threading. Should I be doing this in any scenario that uses a GUI? Would this kind of application require it? | false | 22,999,993 | 0.049958 | 0 | 0 | 1 | One thing I learned from javascript/node.js is that there is a difference between asynchronous programming and parallel programming. In asynchronous programming you may have things running out of sequence, but any given task runs to completion before something else starts running. That way you don't have to worry about synchronizing shared resources with semaphores and locks and things like that, which would be an issue if you have multiple threads running in parallel, with either run simultaneously or might get preempted, thus the need for locks.
Most likely you are doing some sort of asynchronous code in a gui environment, and there isn't any need for you to also do parallel multi-threaded code. | 1 | 106 | 0 | 1 | 2014-04-10T22:08:00.000 | python,multithreading,model-view-controller,python-multithreading | When should I be considering using threading | 0 | 4 | 4 | 23,000,216 | 1 |
0 | 0 | I'm trying to solidify my python knowledge by doing some gui development, should I try Tkinter or jump directly to PyQT for better IDE support? | false | 23,070,926 | 0.197375 | 0 | 0 | 2 | If your main goal is to solidify your python knowledge, I would recommend Tkinter. It's simpler and it's already installed with Python.
If you want to build complex applications, I recommend PyQt, which is way more powerful. | 0 | 2,947 | 0 | 2 | 2014-04-14T21:37:00.000 | python,user-interface,tkinter | Tkinter first or PyQt? | 0 | 1 | 2 | 23,071,223 | 1 |
0 | 0 | I apologize in advance for this being a bit vague, but I'm trying to figure out what the best way is to write my program from a high-level perspective. Here's an overview of what I'm trying to accomplish:
RasPi takes input from altitude sensor on serial port at 115000 baud.
Does some hex -> dec math and updates state variables (pitch, roll, heading, etc)
Uses pygame library to do some image manipulation based on the state variables on a simulated heads up display
Outputs the image to a projector at 30 fps.
Note that there's no user input (for now).
The issue I'm running into is the framerate. The framerate MUST be constant. I'd rather skip a data packet than drop a frame.
There's two ways I could see structuring this:
Write one function that, when called, grabs data from the serial bus and spits out the state variables as the output. Then write a pygame loop that calls this function from inside it. My concern with this is that if the serial port starts being read at the end of an attitude message, it'll have to pause and wait for the message to start again (fractions of a second, but could result in a dropped frame)
Write two separate modules, both to be running simultaneously. One continuously reads data from the serial port and updates the state variables as fast as possible. The other just does the image manipulation, and grabs the latest state variables when it needs them. However, I'm not actually sure how to write a multithreaded program like this, and I don't know how well the RasPi will handle such a program. | false | 23,097,604 | 0 | 1 | 0 | 0 | I don't think that RasPi would work that well running multithreaded programs. Try the first method, though it would be interesting to see the results of a multithreaded program. | 0 | 73 | 0 | 0 | 2014-04-16T01:51:00.000 | python,multithreading,buffer,raspberry-pi | How to structure my Python code? | 0 | 1 | 1 | 23,097,644 | 1 |
0 | 0 | I need to ask a question on how to set a development environment for Kivy under Windows 7. Normally i work with Kivy on Linux, but i need to develop an application for a client who uses Windows. From the Kivy documents, there are two alternatives:
1- Download and Unzip the file containing the Kivy environment plus the Python interpreter with it. I have concerns here. Will this damage my existing Python environment (2.7)? if not is it sand boxed well? Plus if i need to add other third party libraries (ex : pyodbc to run on a Kivy application on a PC) where shall they be installed ?
2- set up Kivy for existing Python environment. Another concern here : is the "unofficial" windows installer a good way to get Kivy running under Windows? and same concerns as above for the Python environment.
Thank you in advance. | true | 23,102,090 | 1.2 | 0 | 0 | 2 | I am using kivy on windows 7 . You can use option 1 . it wont damage your current python 2.7 because you can just change the path of environment to the python interpreter which comes with kivy .
in case you need to turn back to your older python installed just change the environment variables .
Ino order to add third party libraries , most of them are already installed in kivy . for others you can find them on kivy.org :)
If you need to use for example pyQt4 or similar library you need to use different interpreter . I am also doing same stuff .In my case , I use pycharm and keep different configuration (i.e. python interpreter) for different programs . | 1 | 879 | 0 | 1 | 2014-04-16T06:52:00.000 | android,windows,python-2.7,kivy | Kivy development environment on Windows 7 | 0 | 1 | 1 | 23,105,151 | 1 |
0 | 0 | I am currently in a project where a lot of 3D printing designs need to be done. They are all parameterized, so I'd like to write a python code to generate those design files (in .STL format) for me. I was wondering that, is there a python package that can do this? Because currently I am all doing those by hand using SolidWorks.
Thanks! | false | 23,123,384 | 0.132549 | 0 | 0 | 2 | Yes, more than one.
In my humble experience, I tried many Open Source tools for parametric CAD modeling using Python (FreeCAD, Rhino-Grasshopper, Blender, Salome).
All of them are valid options and the best one is represented by your ability to either model or code.
I recently favour SALOME (www.salome-platform.org) because of the straight forward "dump study" option, the continue development and the good API documentation.
Particularly I did some 3d prints using the exportSTL command once I had a solid worthy of printing and it was ok.
Nevertheless, if you intend to work on surfaces rather than solids, I don't think you will find anything worthy Open Source (Rhino has a little price to pay). | 1 | 5,404 | 0 | 4 | 2014-04-17T02:08:00.000 | python,rapid-prototyping | Is there a python library to generate STL file for 3D printing? | 0 | 1 | 3 | 36,361,624 | 1 |
0 | 0 | I have a python script that runs the GUI which is coded using Tkinter.
Problem is when i run the script, there are 2 windows opened. One is the GUI and other is the black console window.
I need to integrate both the windows so that when I start the script only one window appears.
Any ideas are much appreciated.
Thanks in advance. | false | 23,141,471 | 0 | 0 | 0 | 0 | (I am pretty sure there is a better way, but) one way is to change the .pyc object file extension to .pyw and the console will not appear when you launch your GUI using the .pyw file. | 0 | 780 | 0 | 0 | 2014-04-17T19:07:00.000 | python,user-interface,console,tkinter,integration | Integration of console window with GUI using TkInter | 0 | 1 | 2 | 23,141,544 | 1 |
0 | 0 | I'm looking at using Kivy to create a program that needs to display a window on each monitor, is there a way to accomplish this? I'd also prefer not to have a single window spanning across.
If not, is there another (good looking, windows/linux) GUI toolkit that can accomplish this? | true | 23,178,570 | 1.2 | 0 | 0 | 8 | You can have two separate windows running two separate kivy apps controlling/communicating with each other via osc/twisted/... However one "App" instance is only limited to one App window for that process. It can launch another process(subprocess.popen) which has a new window though. | 0 | 1,500 | 0 | 5 | 2014-04-20T04:53:00.000 | python,user-interface,kivy | Multiple monitors with Kivy | 0 | 1 | 1 | 23,179,572 | 1 |
0 | 0 | I want to connect to a mySQL database with python, then query a number corresponding to an image, and load this image in Qt. From what I found online, it is suggested not to use mysql database to store the image, but instead store a file location on the server. If this is the case, can I load the image (do i have to download it?) into qt using mysql or do i have to open another connection with ftp, download the image to a folder, and then load it with qt? If there are any resources on this type of workflow I would appreciate it. | false | 23,190,976 | 0.197375 | 0 | 1 | 1 | You don't need to download the file using FTP (or the like) to load it into Qt.
Assuming the database stores the correct file path to the image, you can just use the same functionality once you get the file path, i.e. you anyway only need the file path to load the image into Qt. There is nothing special you would do by downloading the image itself.
If the database is on a remote server, a possible approach is to use the JDBC API to access the database, get the image as a binary file and then serialize it, which can be transferred over the network. | 0 | 421 | 0 | 0 | 2014-04-21T04:50:00.000 | python,mysql,pyqt | mySQL connection and loading images to Qt | 0 | 1 | 1 | 23,191,497 | 1 |
0 | 0 | I used to have PyGame installed on my PC but formatted my PC and now need it installed again. I have followed the same process as last time and have installed Python 3.3 and PyGame 3.3.0 off of GitBucket. I install PyThon to my only HDD as Python33 and Pygame in a different file on my HDD as PythonX, but for some reason when entering import pygame but it just doesn't find the module. What am I doing wrong? | false | 23,250,659 | 0 | 0 | 0 | 0 | The pygame library must be in site-packages folder in Lib folder of your python folder.
It's better you don't personalize this kind of instalation. Why separate a language of its libraries? | 1 | 108 | 0 | 0 | 2014-04-23T16:52:00.000 | python,pygame | Installing PyGame issues | 0 | 1 | 1 | 28,335,704 | 1 |
0 | 0 | I have made a database file using SQL commands in python. i have used quite a lot of foreign keys as well but i am not sure how to display this data onto qt with python? any ideas? i would also like the user to be able to add/edit/delete data | false | 23,268,179 | 0.099668 | 0 | 1 | 1 | This question is a bit broad, but I'll try answering it anyway. Qt does come with some models that can be connected to a database. Specifically classes like QSqlTableModel. If you connect such a model to your database and set it as the model for a QTableView it should give you most of the behavior you want.
Unfortunately I don't think I can be any more specific than that. Once you have written some code, feel free to ask a new question about a specific issue (remember to include example code!) | 0 | 4,532 | 0 | 1 | 2014-04-24T11:55:00.000 | python,sql,qt,pyqt | How to display data from a database file onto pyqt so that the user can add/delete/edit the data? | 0 | 1 | 2 | 23,281,662 | 1 |
0 | 0 | Does anyone know of an easy way to draw ellipses that are not aligned to the x & y axis. I am very new to pygame so please forgive my ignorance, but I cannot find anything related to it.
If no easy method exists, can someone help me in how I might draw this besides generating many many points on the ellipse and plotting all of them? | false | 23,281,952 | -0.07983 | 0 | 0 | -2 | I do not know python or pygame, but depending on what you are building, it may be easier to just make an image using a program like inkscape for pc and mac, or inkpad for iPad. Both of these let you make a diagonal ellipse, and then export it as a .png and use it in your code. Again, if this is possible really depends on what you are doing with the ellipse. | 0 | 7,513 | 0 | 4 | 2014-04-25T00:01:00.000 | python,pygame | drawing a diagonal ellipse with pygame | 0 | 1 | 5 | 23,282,068 | 1 |
0 | 0 | I'll keep my question short and simple.
Assume I have a python program which calls C++ code from a DLL compiled in C/C++.
-Will the speed/performance of the executing code be preserved?
Assume I have a python program ... has a binding to a C++ library (for example - GTK or Wx).
-Is the speed going to match that of the library as if it was compiled with a C++ program?
Thank you. | true | 23,288,692 | 1.2 | 0 | 0 | 2 | When Python calls into C++ code, the code it executes is the machine code generated by the C++ compiler. You will have some cost at the interface level, as you have to marshal Python types into C++ types and vice versa, but the C++ code itself will run at pretty much the same speed as if it were called from C++; any differences will be due to different locality of dynamically allocated memory due to different memory use patterns (which would cause your C++ code to run at different speeds depending on which C++ application called it as well). | 0 | 1,197 | 0 | 1 | 2014-04-25T09:04:00.000 | python,c++,dll,binding,module | Python bindings; calling C code & performance | 0 | 1 | 1 | 23,289,534 | 1 |
0 | 0 | I'm trying to use the python kled module that's featured in QT Designer under ubuntu 13.10 Unity. Is it possible to use with Unity or will i need to use a KDE environment? | true | 23,305,663 | 1.2 | 0 | 0 | 1 | I use KLed in my PyQt4 gui. Originally it was developed in the Kubuntu environment, so this wasn't an issue, but we ended up having to move to Unity (Ubuntu 14.04 LTS). In order to still use KLed I found that I needed to apt-get install the python libraries from kde (didn't want to install Kubuntu as it interfered with operation).
The fix was:
sudo apt-get install python-kde4
SO the summary answer is:
Yes, you can use KLed in Unity, as long as you have the libraries installed. | 0 | 637 | 0 | 0 | 2014-04-26T01:50:00.000 | python,pyqt,qt-designer | PyQt kled in Unity enviornmet? | 0 | 1 | 1 | 25,923,294 | 1 |
0 | 0 | i build my GUI with wxGlade. I think it is very comfortable but i´m looking for a widget/button which open a frame to chose a directory or file..
Can u help me? | false | 23,310,229 | 0 | 0 | 0 | 0 | WxGlade does not directly support a adding a wx.FileDialog to your GUI. As someone answer you have to create and event linked to a button,menu,or toolbar then in your code enter the programming to open a filedialog and return text from it. What I normally do is use the toolbox button to create a generic dialog box and then name it open or save or something that will remind me that I will need to edit that piece of the wxGlade generated python code into and actual filedialog. That saves me a bit of time of typing ALL the code for a filedialog into the program. | 0 | 1,034 | 0 | 0 | 2014-04-26T11:31:00.000 | python,wxpython,wxglade | wxGlade - Button to chose directory and file | 0 | 1 | 2 | 28,642,528 | 1 |
0 | 0 | A friend and I are making a game in pygame. We would like to have a pygame window embedded into a tkinter or WxPython frame, so that we can include text input, buttons, and dropdown menus that are supported by WX or Tkinter. I have scoured the internet for an answer, but all I have found are people asking the same question, none of these have been well answered.
What would be the best way implement a pygame display embedded into a tkinter or WX frame? (TKinter is preferable)
Any other way in which these features can be included alongside a pygame display would also work. | false | 23,319,059 | 0.066568 | 0 | 0 | 1 | According to the tracebacks, the program crashes due to TclErrors. These are caused by attempting to access the same file, socket, or similar resource in two different threads at the same time. In this case, I believe it is a conflict of screen resources within threads. However, this is not, in fact, due to an internal issue that arises with two gui programs that are meant to function autonomously. The errors are a product of a separate thread calling root.update() when it doesn't need to because the main thread has taken over. This is stopped simply by making the thread call root.update() only when the main thread is not doing so. | 0 | 31,504 | 0 | 24 | 2014-04-27T03:30:00.000 | python,tkinter,wxpython,pygame,embed | Embedding a Pygame window into a Tkinter or WxPython frame | 0 | 1 | 3 | 23,683,962 | 1 |
0 | 0 | I'm new to this so sorry it if doesn't make much sense.
I'v created a simple 2d game with Python 3.4 and Pygame and I want to create an exe file that includes python 3.4, the pygame module, the game files and launches the python game file when opened.
Thanks. | true | 23,319,956 | 1.2 | 0 | 0 | 1 | If you're using Python 3.x, you can use cx_Freeze. | 1 | 271 | 0 | 2 | 2014-04-27T06:00:00.000 | python,file,pygame,directory,exe | How do I turn a Pygame Folder into an application (eg .exe)? | 0 | 1 | 2 | 23,372,498 | 1 |
0 | 0 | I'm a trainee novice programmer.
I have / am creating simple programs, generally around screen scraping, data caption (postrgres), various processing methods and now a GUI via wxpython
I find a lot of these programs overlap - ie use same techniques, and get some very long copied and pasted programs!
Overtime I improve these techniques and find myself having to backtrack over multiple programs to update these.
How? Can I? Create a more dynamic, systematic process.
One where all programs / procedures / classes are shared?
Has it got a name?
My logical thought is that like 'procedures' and 'classes' I have would have smaller low level programs and mid level programs that called upon these - the GUI being the top program! but this would mean passing data to and from! Can Classes and Procedures be separate programs?
Many thanks
Cameron | true | 23,362,560 | 1.2 | 0 | 0 | 1 | There is a range of techniques you can use :
Shared modules - A set of modules with well defined interfaces - functions, classes etc. These modules sit in a folders which every application you use can get to - i.e. the path to the folder is added to PYTHON_PATH environment variable. These interfaces should be engineered so when you add functionality to them they don't break the old applications.
Design patterns - Design your applications with a good design pattern - MVC (Master View Controller) is a useful one for GUI programs. V is your GUI - and exposes only a few methods, which aren't actually dependent on the GUI itself (for instances methods such as display_foo). The Master is your data access functionality - again with well defined interfaces. Controller interfaces between View and Master. There may be other patterns which apply to your application too. | 1 | 152 | 0 | 1 | 2014-04-29T10:51:00.000 | python,class,sharing | How do I go make my Python code more efficient and dynamic? | 0 | 1 | 2 | 23,362,812 | 1 |
0 | 0 | I'm trying to use the data collected by a form I to a sqlite query. In this form I've made a spin button which gets any numeric input (ie. either2,34 or 2.34) and sends it in the form of 2,34 which python sees as str.
I've already tried to float() the value but it doesn't work. It seems to be a locale problem but somehow locale.setlocale(locale.LC_ALL, '') is unsupported (says WinXP).
All these happen even though I haven't set anything to greek (language, locale, etc) but somehow Windows does its magic.
Can someone help?
PS: Of course my script starts with # -*- coding: utf-8 -*- so as to have anything in greek (even comments) in the code. | true | 23,388,647 | 1.2 | 0 | 1 | 1 | AFAIK, WinXP supports setlocale just fine.
If you want to do locale-aware conversions, try using locale.atof('2,34') instead of float('2,34'). | 0 | 48 | 0 | 0 | 2014-04-30T12:53:00.000 | python,sqlite,pygtk | pygtk spinbutton "greek" floating point | 0 | 1 | 1 | 23,389,055 | 1 |
0 | 0 | I do not have any code to show with this question because I am just seeking advice. I have a functional piece of code and through the execution of which I create approx 20 - 30 unique panels. I only use one at any given time (with a few small exceptions) and I use show/hide to manage which panels are displayed at a given time.
My question is this: Is it best that I create all 30 panels at the inception point of the code, hide the 29 that are not needed and move on, and then show/hide between the 30 panels as the code runs, or should I only create the one or two that are needed at the start and create the others as they are called for and then hide/destroy the ones that have served their purpose. | true | 23,415,765 | 1.2 | 0 | 0 | 0 | There are a couple of approaches. The first is to just create all of the panels that you need and hide them as you've been doing. Another approach would be to create the sizers with the widgets laid out appropriately and just hide the sizers as needed. This way you would only ever have one or two panels, but different layouts. | 0 | 16 | 0 | 0 | 2014-05-01T20:10:00.000 | wxpython,panel | wxpython create multiple panels at start or as the program progresses | 0 | 1 | 1 | 23,416,753 | 1 |
0 | 0 | I encountered Error: 'module' object has no attribute 'copy' while running a pygame program. In my code, I never referred to a copy attribute, so I don't understand where the error is coming from. | true | 23,418,949 | 1.2 | 0 | 0 | 21 | I think there is a python file named "copy" in your directory. I had the same problem, after I delete the "copy" file, the error has gone. | 1 | 11,076 | 0 | 6 | 2014-05-02T00:33:00.000 | module,pygame,python-2.5,attributeerror,traceback | Pygame AttributeError: 'module' object has no attribute 'copy' | 0 | 1 | 1 | 31,551,977 | 1 |
0 | 0 | How can I make a PyQt5 application to look like the same when run on Windows, and Linux?
I would prefer the Windows style on both systems.
Thanks | true | 23,427,939 | 1.2 | 0 | 0 | 3 | You can call QApplication::setStyle("windows") before creating QApplication object to set a style by name. However, Qt on Linux is usually built without modern Windows styles, so it's possible that the best you will accomplish is the classic (old) Windows style, which is not very attractive. You can also try to use "fusion" style or other values that QStyleFactory::keys() returns. | 0 | 1,984 | 0 | 0 | 2014-05-02T12:14:00.000 | python,qt,pyqt | Make PyQt application look like the same on Windows and Linux | 0 | 2 | 2 | 23,436,083 | 1 |
0 | 0 | How can I make a PyQt5 application to look like the same when run on Windows, and Linux?
I would prefer the Windows style on both systems.
Thanks | false | 23,427,939 | 0 | 0 | 0 | 0 | You can use existing styles mentioned above
or you can specify the styles of your widgets using Stylesheet, which is quite powerful. | 0 | 1,984 | 0 | 0 | 2014-05-02T12:14:00.000 | python,qt,pyqt | Make PyQt application look like the same on Windows and Linux | 0 | 2 | 2 | 23,474,604 | 1 |
0 | 0 | I finally managed to write a little app that reads from a sqlite database and show the results to a treeview. Another form (in another module) gives the ability to write new or update existing records. After writing to the database it closes the window
What I'm trying to do now is to update the "main" window (containing the treeview) to show the new dataset. I have managed so far to do this but a) the initial mainwindow stays there while a new instance of it opens on top of it showing the desired (new) dataset.
How would I make this work? Can someone give me suggestions/example?
Perhaps I need to say that the __init__ function of my mainwindow module does everything upon running: creates the gui, reads from the database and show all. I suspect that this may be the problem but having tryed almost any combination of breaking it into pieces (functions), I had no success
--EDIT--
OK I have many different functions __init__ now creates the main gui while others read the data from the DB and place it on a treeview.
I tried to use a timer but also this option doesn't seem to be apropriate as gtk.TreeView doesn't have such a method. | true | 23,428,618 | 1.2 | 0 | 0 | 8 | Finally I managed to figure this out, so I post this answer to my own question in case someone finds it helpful:
All I had to do was to .clear the list_store, rebuild it and use set_model to the TreeView.
The refresh function goes as below:
liststore.clear()
create_model_checks() # re-create liststore
treeView.set_model(liststore) | 0 | 3,427 | 0 | 6 | 2014-05-02T12:49:00.000 | python,sqlite,treeview | pygtk treeview contents update/refresh | 0 | 1 | 1 | 23,489,182 | 1 |
0 | 0 | I have a scene, and I need to be able to overlay the scene with translucent polygons (which can be done easily using pygame.gfxdraw.filled_polygon which supports drawing with alpha), but the catch is that the amount of translucency has to fade over a distance (so for example, if the alpha value is 255 at one end of the polygon, then it is 0 at the other end and it blends from 255 to 0 through the polygon). I've implemented drawing shapes with gradients by drawing the gradient and then drawing a mask on top, but I've never come across a situation like this, so I have no clue what to do. I need a solution that can run in real time. Does anyone have any ideas? | true | 23,439,474 | 1.2 | 0 | 0 | 0 | It is possible that you have already thought of this and have decided against it, but it would obviously run far better in real time if the polygons were pre-drawn. Presuming there aren't very many different types of polygons, you could even resize them however you need and you would be saving CPU.
Also, assuming that all of the polygons are regular, you could just have several different equilateral triangles with gradients going in various directions on them to produce the necessary shapes.
Another thing you could do is define the polygon you are drawing, than draw an image of a gradient saved on your computer inside that shape.
The final thing you could do is to build your program (or certain, CPU intensive parts of your program) in C or C++. Being compiled and automatically optimized during compiling, these languages are significantly faster than python and better suited to what you are trying to do. | 0 | 948 | 0 | 2 | 2014-05-03T02:08:00.000 | python,pygame,alpha | Gradient alpha polygon with pygame | 0 | 1 | 1 | 23,485,047 | 1 |
0 | 0 | I have very complicated problem. I´ve search whole internet and tried everything, but nothing worked. I want get string from listbox and than delete line in file with word from listbox. Can please somebody help me? Here is code:
def OnDelete(self, event):
sel = self.listbox.GetSelection()
if sel != -1:
self.listbox.Delete(sel)
subor = open("Save/savegame.txt", "r")
lines = subor.readlines()
subor.close()
subor = open("Save/savegame.txt", "w")
selstring = self.listbox.GetString(self.listbox.GetSelection())
for line in lines:
if line!=selstring:
subor.write(line)
subor.close()
And this is code for saving file:
def OnNewGame(self,event):
nameofplr = wx.GetTextFromUser('Enter your name:', 'NEW GAME')
subor=open("Save/savegame.txt","a")
subor.write( "\n" + nameofplr)
subor.close()
savegame=open("Save/" + nameofplr + ".prjct", "w+")
savegame.close()
It shows this error:
Traceback (most recent call last):
File "D:\Python\Python Projects\Project\Project.py", line 106, in OnDelete
selstring = self.listbox.GetString(self.listbox.GetSelection())
File "D:\Python\lib\site-packages\wx-3.0-msw\wx_core.py", line 12962, in GetString
return core.ItemContainer_GetString(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "IsValid(n)" failed at ....\src\msw\listbox.cpp(387) in wxListBox::GetString(): invalid index in wxListBox::GetString
Thank you very much for help! | false | 23,448,140 | 0 | 0 | 0 | 0 | Than you very much! I have fixed it! If somebody will have the same problem you must change OnDelete code (The first code in question) for this:
def OnDelete(self, event):
sel = self.listbox.GetSelection()
f = open("Save/savegame.txt", "r")
read = f.readlines()
f.close()
name = self.listbox.GetStringSelection()
newfile = """"""
for i in read:
if name in i:
pass
else:
newfile += i
n = open("Save/savegame.txt", "w")
one = str(newfile)
n.write(one)
n.close
self.listbox.Delete(sel) | 0 | 817 | 0 | 0 | 2014-05-03T18:11:00.000 | string,listbox,wxpython | How to get string from listbox | 0 | 1 | 2 | 23,455,859 | 1 |
0 | 0 | I am using wxPython for a board game. And want to drag chessman over positions.
What is the container I should use? Should I put image for chessman in its own panel or as button or somewhere? | true | 23,464,220 | 1.2 | 0 | 0 | 1 | I think you could use a wx.Panel without any issues. There is a CustomDragAndDrop example in the wxPython demo that shows how to drag and drop images from one wx.Window to another. A wx.Panel is a type of wx.Window and I would think it would be better to use anyway. I would give that a try. | 0 | 68 | 0 | 0 | 2014-05-05T03:13:00.000 | image,drag-and-drop,wxpython | wxPython -- Drag and Drop image between position-fixed containers, what is the suitable container? | 0 | 1 | 1 | 23,479,767 | 1 |
0 | 0 | I am working with an embedded python system which requires a C++ frontend using OpenSceneGraph for rendering visualizations. My question is:
Is there any possible way to perform this task? I need to modify C++ osg nodes from Python. Would it be an option to create wrappers for this osg nodes? If this is the answer could you provide some guidance? | true | 23,467,814 | 1.2 | 0 | 0 | 0 | Finally I managed to solve this issue by creating a new python type (python extension) and using Node Visitors to assign node references upon creation. | 0 | 741 | 0 | 0 | 2014-05-05T08:12:00.000 | python,c++,openscenegraph | How can I use C++ OSG objects from Python? | 0 | 1 | 3 | 23,624,458 | 1 |
0 | 0 | I'm implementing an algorithm into my Python web application, and it includes doing some (possibly) large clustering and matrix calculations. I've seen that Python can use C/C++ libraries, and thought that it might be a good idea to utilize this to speed things up.
First: Are there any reasons not to, or anything I should keep in mind while doing this?
Second: I have some reluctance against connecting C to MySQL (where I would get the data the calculations). Is this in any way justified? | false | 23,491,608 | 0.066568 | 1 | 0 | 1 | Not the answer you expected, but i have been down that road and advise KISS:
First make it work in the most simple way possible.
Only than look into speeding things up later / complicating the design.
There are lots of other ways to phrase this such as "do not fix hypothetical problems unless resources are unlimited". | 0 | 1,084 | 0 | 4 | 2014-05-06T10:04:00.000 | python,c++,mysql,c | Using C/C++ for heavy calculations in Python (Also MySQL) | 0 | 3 | 3 | 23,493,503 | 1 |
0 | 0 | I'm implementing an algorithm into my Python web application, and it includes doing some (possibly) large clustering and matrix calculations. I've seen that Python can use C/C++ libraries, and thought that it might be a good idea to utilize this to speed things up.
First: Are there any reasons not to, or anything I should keep in mind while doing this?
Second: I have some reluctance against connecting C to MySQL (where I would get the data the calculations). Is this in any way justified? | true | 23,491,608 | 1.2 | 1 | 0 | 1 | Use the ecosystem.
For matrices, using numpy and scipy can provide approximately the same range of functionality as tools like Matlab. If you learn to write idiomatic code with these modules, the inner loops can take place in the C or FORTRAN implementations of the modules, resulting in C-like overall performance with Python expressiveness for most tasks. You may also be interested in numexpr, which can further accelerate and in some cases parallelize numpy/scipy expressions.
If you must write compute-intensive inner loops in Python, think hard about it first. Maybe you can reformulate the problem in a way more suited to numpy/scipy. Or, maybe you can use data structures available in Python to come up with a better algorithm rather than a faster implementation of the same algorithm. If not, there’s Cython, which uses a restricted subset of Python to compile to machine code.
Only as a last resort, and after profiling to identify the absolute worst bottlenecks, should you consider writing an extension module in C/C++. There are just so many easier ways to meet the vast majority of performance requirements, and numeric/mathematical code is an area with very good existing library support. | 0 | 1,084 | 0 | 4 | 2014-05-06T10:04:00.000 | python,c++,mysql,c | Using C/C++ for heavy calculations in Python (Also MySQL) | 0 | 3 | 3 | 23,497,013 | 1 |
0 | 0 | I'm implementing an algorithm into my Python web application, and it includes doing some (possibly) large clustering and matrix calculations. I've seen that Python can use C/C++ libraries, and thought that it might be a good idea to utilize this to speed things up.
First: Are there any reasons not to, or anything I should keep in mind while doing this?
Second: I have some reluctance against connecting C to MySQL (where I would get the data the calculations). Is this in any way justified? | false | 23,491,608 | 0.066568 | 1 | 0 | 1 | cython support for c++ is much better than what it was. You can use most of the standard library in cython seamlessly. There are up to 500x speedups in the extreme best case.
My experience is that it is best to keep the cython code extremely thin, and forward all arguments to c++. It is much easier to debug c++ directly, and the syntax is better understood. Having to maintain a code base unnecessarily in three different languages is a pain.
Using c++/cython means that you have to spend a little time thinking about ownership issues. I.e. it is often safest not to allocate anything in c++ but prepare the memory in python / cython. (Use array.array or numpy.array). Alternatively, make a c++ object wrapped in cython which has a deallocation function. All this means that your application will be more fragile than if it is written only in python or c++: You are abandoning both RAII / gc.
On the other hand, your python code should translate line for line into modern c++. So this reminds you not to use old fashioned new or delete etc in your new c++ code but make things fast and clean by keeping the abstractions at a high level.
Remember too to re-examine the assumptions behind your original algorithmic choices. What is sensible for python might be foolish for c++.
Finally, python makes everything significantly simpler and cleaner and faster to debug than c++. But in many ways, c++ encourages more powerful abstractions and better separation of concerns.
When you programme with python and cython and c++, it slowly comes to feel like taking the worse bits of both approaches. It might be worth biting the bullet and rewriting completely in c++. You can keep the python test harness and use the original design as a prototype / testbed. | 0 | 1,084 | 0 | 4 | 2014-05-06T10:04:00.000 | python,c++,mysql,c | Using C/C++ for heavy calculations in Python (Also MySQL) | 0 | 3 | 3 | 23,497,054 | 1 |
0 | 0 | How do you go about selecting a specific line in a QTextEdit and changing say... The font colour to green
I am using a QTextEdit widget to display the content of a file, a sequence of commands being sent over rs232. I would like to provide some visual feedback as to what line is being executed, say change the text colour.
I am able to change the text file of text being appended to a QTextEdit (for a log I display) but that doesn't work.
I have been looking into Qcursors but am a bit lost | false | 23,550,613 | 0.066568 | 0 | 0 | 1 | I think that you can afford generating a new TextEdit content from the relevant data, every time something changes. That should be very easy to implement. QCursors and stuff like that is good for editable QTextEdits which is not true in your case. And there is no guarantee that it will be faster at all. | 0 | 2,307 | 0 | 0 | 2014-05-08T19:14:00.000 | python,pyqt4 | format a specific line in a QtextEdit | 0 | 1 | 3 | 23,551,836 | 1 |
0 | 0 | I have a multi-threaded (via pyqt) application which plots realtime data (data is processed in the second thread and passed to the gui thread to plot via a pyqt-signal). If I place the mouse over the application it continues to run at full speed (as measured by the time difference between calls to app.processEvents()). As soon as I begin moving the mouse, the update rate slows to a crawl, increasing again when I stop moving the mouse.
Does anyone know how I can resolve this/debug the issue?
The code is quite lengthy and complex so I'd rather not post it here. Thanks! | false | 23,567,726 | 0.379949 | 0 | 0 | 2 | It's likely you have items in the scene that accept their own mouse input, but it's difficult to say without seeing code. In particular, be wary of complex plot lines that are made clickable--it is very expensive to compute the intersection of the mouse cursor with such complex shapes.
The best (some would say only) way to solve performance issues is to profile your application: run python -m cProfile -s cumulative your_script.py once without moving the mouse, and again with mouse movement (be sure to spend plenty of time moving the mouse), and then compare the outputs to see where the interpreter is spending all of its time. | 0 | 742 | 0 | 0 | 2014-05-09T14:53:00.000 | python,qt,pyqt,pyqtgraph | PYQTGraph application slows down when mouse moves over application | 0 | 1 | 1 | 23,572,444 | 1 |
0 | 0 | I'm preparing exercises for school classes involving Python's turtle library.
The students are already drawing terrific pictures, but I want them to be able to detect existing pictures and colours in order to modify the behaviour of their program.
For example I would like to provide them with code which draws a maze using turtle, and then they can write the code to navigate the turtle around the maze (don't worry, I'll start simpler).
Is there a way to detect the colour of the pixels already drawn by the turtle?
Thanks! | false | 23,579,631 | 0 | 0 | 0 | 0 | I would use an array keep all x and y that is used for the maze in an array like stated above. Then have a size of a box around the turtle defined for detecting purposes. | 1 | 3,154 | 0 | 3 | 2014-05-10T09:57:00.000 | python,turtle-graphics | How to read pixel colours using Python turtle.py | 0 | 1 | 2 | 51,011,317 | 1 |
0 | 0 | I have a static library I created from C++, and would like to test this using a Driver code.
I noticed one of my professors like to do his tests using python, but he simply executes the program (not a library in this case, but an executable) using random test arguments.
I would like to take this approach, but I realized that this is a library and doesn't have a main function; that would mean I should either create a Driver.cpp class, or wrap the library into python using SWIG or boost python.
I’m planning to do the latter because it seems more fun, but logically, I feel that there is going to be more bugs when trying to wrap a library to a different language just to test it, rather than test it in its native language.
Is testing programs in a different language an accepted practice in the real world, or is this bad practice? | false | 23,622,923 | 0.197375 | 1 | 0 | 5 | It really depends on what it is you are trying to test. It almost always makes sense to write unit tests in the same language as the code you are testing so that you can construct the objects under test or invoke the functions under test, both of which can be most easily done in the same language, and verify that they work correctly. There are, however, cases in which it makes sense to use a different language, namely:
Integration tests that run a number of different components or applications together.
Tests that verify compilation or interpretation failures which could not be tested in the language, itself, since you are validating that an error occurs at the language level.
An example of #1 might be a program that starts up multiple different servers connected to each other, issues requests to the server, and verifies those responses. Or, as a simpler example, a program that simply forks an application under test as a subprocess and verifies that it produces the expected outputs for a given input.
An example of #2 might be a program that verifies that a certain piece of C++ code will produce a static assertion failure or that a particular template instantiation which is intentionally disallowed will result in a compilation failure if someone attempts to use it.
To answer your larger question, it is not bad practice per-se to write tests in a different language. Whatever makes the tests more convenient to write, easier to understand, more robust to changes in implementation, more sensitive to regressions, and better on any one of the properties that define good testing would be a good justification to write the tests one way vs another. If that means writing the tests in another language, then go for it. That being said, small unit tests typically need to be able to invoke the item under test directly which, in most cases, means writing the unit tests in the same language as the component under test. | 0 | 4,198 | 0 | 28 | 2014-05-13T04:40:00.000 | python,c++,unit-testing | Is it acceptable practice to unit-test a program in a different language? | 0 | 5 | 5 | 23,623,089 | 1 |
0 | 0 | I have a static library I created from C++, and would like to test this using a Driver code.
I noticed one of my professors like to do his tests using python, but he simply executes the program (not a library in this case, but an executable) using random test arguments.
I would like to take this approach, but I realized that this is a library and doesn't have a main function; that would mean I should either create a Driver.cpp class, or wrap the library into python using SWIG or boost python.
I’m planning to do the latter because it seems more fun, but logically, I feel that there is going to be more bugs when trying to wrap a library to a different language just to test it, rather than test it in its native language.
Is testing programs in a different language an accepted practice in the real world, or is this bad practice? | false | 23,622,923 | 0.158649 | 1 | 0 | 4 | Why not, it's an awesome idea because you really understand that you are testing the unit like a black box.
Of course there may be technical issues involved, what if you need to mock some parts of the unit under test, that may be difficult in a different language.
This is a common practice for integration tests though, I've seen lots of programs driven from external tools such as a website from selenium, or an application from cucumber. Both those can be considered the same as a custom python script.
If you consider the difference between integration testing and unit testing is the number of things under test at any given time, the only reason why you shouldn't do this is tool support. | 0 | 4,198 | 0 | 28 | 2014-05-13T04:40:00.000 | python,c++,unit-testing | Is it acceptable practice to unit-test a program in a different language? | 0 | 5 | 5 | 23,623,087 | 1 |
0 | 0 | I have a static library I created from C++, and would like to test this using a Driver code.
I noticed one of my professors like to do his tests using python, but he simply executes the program (not a library in this case, but an executable) using random test arguments.
I would like to take this approach, but I realized that this is a library and doesn't have a main function; that would mean I should either create a Driver.cpp class, or wrap the library into python using SWIG or boost python.
I’m planning to do the latter because it seems more fun, but logically, I feel that there is going to be more bugs when trying to wrap a library to a different language just to test it, rather than test it in its native language.
Is testing programs in a different language an accepted practice in the real world, or is this bad practice? | false | 23,622,923 | 0.158649 | 1 | 0 | 4 | I would say it depends on what you're actually trying to test. For true unit testing, it is, I think, best to test in the same language, or at least a binary-compatible language (i.e. testing Java with Groovy -- I use Spock in this case, which is Groovy based, to unit-test my Java code, since I can intermingle the Java with the Groovy), but if you are testing results, then I think it's fair to switch languages.
For example, I have tested the expected results when given a specific set of a data when running a Perl application via nose in Python. This works because I'm not unit testing the Perl code, per se, but the outcomes of that Perl code.
In that case, to unit test actual Perl functions that are part of the application, I would use a Perl-based test framework such as Test::More. | 0 | 4,198 | 0 | 28 | 2014-05-13T04:40:00.000 | python,c++,unit-testing | Is it acceptable practice to unit-test a program in a different language? | 0 | 5 | 5 | 23,623,031 | 1 |
0 | 0 | I have a static library I created from C++, and would like to test this using a Driver code.
I noticed one of my professors like to do his tests using python, but he simply executes the program (not a library in this case, but an executable) using random test arguments.
I would like to take this approach, but I realized that this is a library and doesn't have a main function; that would mean I should either create a Driver.cpp class, or wrap the library into python using SWIG or boost python.
I’m planning to do the latter because it seems more fun, but logically, I feel that there is going to be more bugs when trying to wrap a library to a different language just to test it, rather than test it in its native language.
Is testing programs in a different language an accepted practice in the real world, or is this bad practice? | false | 23,622,923 | 1 | 1 | 0 | 9 | A few things to keep in mind:
If you are writing tests as you code, then, by all means, use whatever language works best to give you rapid feedback. This enables fast test-code cycles (and is fun as well). BUT.
Always have well-written tests in the language of the consumer. How is your client/consumer going to call your functions? What language will they be using? Using the same language minimizes integration issues later on in the life-cycle. | 0 | 4,198 | 0 | 28 | 2014-05-13T04:40:00.000 | python,c++,unit-testing | Is it acceptable practice to unit-test a program in a different language? | 0 | 5 | 5 | 23,623,093 | 1 |
0 | 0 | I have a static library I created from C++, and would like to test this using a Driver code.
I noticed one of my professors like to do his tests using python, but he simply executes the program (not a library in this case, but an executable) using random test arguments.
I would like to take this approach, but I realized that this is a library and doesn't have a main function; that would mean I should either create a Driver.cpp class, or wrap the library into python using SWIG or boost python.
I’m planning to do the latter because it seems more fun, but logically, I feel that there is going to be more bugs when trying to wrap a library to a different language just to test it, rather than test it in its native language.
Is testing programs in a different language an accepted practice in the real world, or is this bad practice? | true | 23,622,923 | 1.2 | 1 | 0 | 28 | I'd say that it's best to test the API that your users will be exposed to. Other tests are good to have as well, but that's the most important aspect.
If your users are going to write C/C++ code linking to your library, then it would be good to have tests making use of your library the same way.
If you are going to ship a Python wrapper (why not?) then you should have Python tests.
Of course, there is a convenience aspect to this, as well. It may be easier to write tests in Python, and you might have time constraints that make it more appealing, etc.
I guess what I'm saying is: There's nothing inherently wrong with tests being in a different language from the code under test (that's totally normal for testing a REST API, for instance), but make sure you have tests for the public-facing API at a minimum.
Aside, on terminology:
I don't think the types of tests you are describing are "unit tests" in the usual sense of the term. Probably "functional test" would be more accurate.
A unit test typically tests a very small component - such as a function call - that might be one piece of larger functionality. Unit tests like these are often "white box" tests, so you can see the inner workings of your code.
Testing something from a user's point-of-view (such as your professor's commandline tests) are "black box" tests, and in these examples are at a more functional level rather than "unit" level.
I'm sure plenty of people may disagree with that, though - it's not a rigidly-defined set of terms. | 0 | 4,198 | 0 | 28 | 2014-05-13T04:40:00.000 | python,c++,unit-testing | Is it acceptable practice to unit-test a program in a different language? | 0 | 5 | 5 | 23,623,088 | 1 |
1 | 0 | I've a strange issue. pserve --reload has stopped reloading the templates. It is reloading if some .py-file is changing, but won't notice .mak-file changes anymore.
I tried to fix it by:
Checking the filepermissions
Creating the new virtualenv, which didn't help.
Installing different version of mako without any effect.
Checking that the python is used from virtualenv
playing with the development.ini. It has the flag: pyramid.reload_templates = true
Any idea how to start debugging the system?
Versions:
Python 2.7
pyramid 1.5
pyramid_mako 1.02
mako 0.9.1
Yours
Heikki | false | 23,646,485 | 0.099668 | 1 | 0 | 1 | Oh my,
I found the thing... I had <%block cached="True" cache_key="${self.filename}+body"> and the file inclusion was inside of that block.
Cheerious:) | 0 | 216 | 0 | 0 | 2014-05-14T05:42:00.000 | python,pyramid,mako,waitress | Pyramid Mako pserver --reload not reloading in Mac | 0 | 1 | 2 | 23,654,584 | 1 |
0 | 0 | I am developing a simple standalone, graphical application in python. My development has been done on linux but I would like to distribute the application cross-platform.
I have a launcher script which checks a bunch of environment variables and then sets various configuration options, and then calls the application with what amounts to python main.py (specifically os.system('python main.py %s'% (arg1, arg2...)) )
On OS X (without X11), the launcher script crashed with an error like Could not run application, need access to screen. A very quick google search later, the script was working locally by replacing python main.py with pythonw main.py.
My question is, what is the best way to write the launcher script so that it can do the right thing across platforms and not crash? Note that this question is not asking how to determine what platform I am on. The solution "check to see if I am on OS X, and if so invoke pythonw instead" is what I have done for now, but it seems like a somewhat hacky fix because it depends on understanding the details of the windowing system (which could easily break sometime in the future) and I wonder if there is a cleaner way.
This question does not yet have a satisfactory answer. | false | 23,659,248 | 0 | 0 | 0 | 0 | Firstly, you should always use .pyw for GUIs.
Secondly, you could convert it to .exe if you want people without python to be able to use your program. The process is simple. The hardest part is downloading one of these:
for python 2.x: p2exe
for python 3.x: cx_Freeze
You can simply google instructions on how to use them if you decide to go down that path.
Also, if you're using messageboxes in your GUI, it won't work. You will have to create windows/toplevels instead. | 0 | 933 | 1 | 1 | 2014-05-14T15:40:00.000 | python,user-interface,cross-platform | python or pythonw in creating a cross-platform standalone GUI app | 0 | 2 | 2 | 23,660,787 | 1 |
0 | 0 | I am developing a simple standalone, graphical application in python. My development has been done on linux but I would like to distribute the application cross-platform.
I have a launcher script which checks a bunch of environment variables and then sets various configuration options, and then calls the application with what amounts to python main.py (specifically os.system('python main.py %s'% (arg1, arg2...)) )
On OS X (without X11), the launcher script crashed with an error like Could not run application, need access to screen. A very quick google search later, the script was working locally by replacing python main.py with pythonw main.py.
My question is, what is the best way to write the launcher script so that it can do the right thing across platforms and not crash? Note that this question is not asking how to determine what platform I am on. The solution "check to see if I am on OS X, and if so invoke pythonw instead" is what I have done for now, but it seems like a somewhat hacky fix because it depends on understanding the details of the windowing system (which could easily break sometime in the future) and I wonder if there is a cleaner way.
This question does not yet have a satisfactory answer. | false | 23,659,248 | 0 | 0 | 0 | 0 | If you save the file as main.pyw, it should run the script without opening up a new cmd/terminal.
Then you can run it as python main.pyw | 0 | 933 | 1 | 1 | 2014-05-14T15:40:00.000 | python,user-interface,cross-platform | python or pythonw in creating a cross-platform standalone GUI app | 0 | 2 | 2 | 23,659,489 | 1 |
0 | 0 | So I've been making a game using Python, specifically the PyGame module. Everything has been going fairly well (except Python's speed, am I right :P), and I've got a nice list of accomplishments from this, but I just ran into a... speedbump. Maybe a mountain. I'm not to sure yet. The problem is:
How do I go about implementing a Camera with my current engine?
That probably means nothing to you, though, so let me explain what my current engine is doing: I have a spritesheet that I use for all images. The map is made up of a double array of Tile objects, which fills up the display (800 x 640). The map also contains references to all Entity's and Particles. So now I want to create a a camera, so that the map object can be Larger than the display. To do this I've devised that I'll need some kind of camera that follows the player (with the player at the center of the screen). I've seen this implemented before in games, and even read a few other similar posts, but I need to also know Will I have to restructure all game code to work this in? My first attempt was to make all object move on the screen when the player moves, but I feel that there is a better way to do this, as this screws up collision detection and such.
So, if anyone knows any good references to problems like this, or a way to fix it, I'm all ears... er.. eyes.
Thanks | false | 23,666,333 | 0 | 0 | 0 | 0 | Since I can't have a look into your code, I can't assess how useful this answer will be for you.
My approach for side scroller, moveable maps, etc. is to blit all tiles onto a pygame.Surface spanning the dimensions of the whole level/map/ etc. or at least a big chunk of it. This way I have to blit only one surface per frame which is already prepared.
For collision detection I keep the x/y values (not the entire rect) of the tiles involved in a separate list. Updating is then mainly shifting numbers around and not surfaces anymore.
Feel free to ask for more details, if you deem it useful :) | 0 | 2,049 | 0 | 0 | 2014-05-14T22:38:00.000 | python,camera,pygame,2d-games | 2D Game Engine - Implementing a Camera | 0 | 1 | 2 | 23,671,391 | 1 |
0 | 0 | I just used py2exe to compile my python app that uses pyqt. The size of it is 23MB.
The Pyqt libraries (PyQt4.QtCore.pyd, PyQt4.QtGui.pyd, QtCore4.dll and QtGui4.dll) sum more than 17MB.
Is there a way to use QT with a reduced size?
Thank you! | false | 23,678,753 | 0 | 0 | 0 | 0 | PyQt is essentially a wrapper around Qt.
In theory it should be possible to use Qt without PyQt, but you'd have to make the bindings yourself. | 0 | 475 | 0 | 0 | 2014-05-15T12:51:00.000 | python,pyqt,py2exe | Reduce Size py2exe and pyqt | 0 | 1 | 1 | 23,681,056 | 1 |
0 | 0 | I have a tkinter program written in python 3.3.3. I see myself in the need of making the the program get focus when the user unlocks the computer. I don't really know how to go ahead and start with this, users have a .exe version of the program that I created with cxfreeze. I f i need to modify the .py and create another .exe, that wouldn't be a problem.
After some research I found that one can use the ctypes module to lock the computer, but it's not very helpful because i need to know if it is locked or unlocked. I also saw commands from win32com, but i can't seem to be able to find a way to trigger a command when it gets unlocked.
What is the best way to get focus on my program after the computer is unlocked??
Any help is greatly appreciated. | false | 23,691,819 | 0 | 0 | 0 | 0 | I cannot answer this specifically for 'unlock' event (if there even is one in the GUI; I can't find one by cursory search.).
But I think the real answer is to change the question. Having a program simply take focus when user unlocks the display is very un-Windows-ish behavior. The Windows user expects to see the desktop just as s/he left it before the display was locked -- why does s/he want to see your program on top when unlocking, regardless of why Windows might have locked the display?
Maybe you want to recast your program as something that runs in the background and pops up a notification (in the notification area on the right side of toolbar) when it wants user to do something? | 0 | 100 | 0 | 0 | 2014-05-16T02:43:00.000 | python,python-3.x,tkinter | Get focus on tkinter program after pc is unlocked | 0 | 1 | 1 | 23,704,276 | 1 |
0 | 0 | Can i compile files like:
- Images,
- sounds,
- fonts,
- etc..
For example if I have "click.wav" and i dont want to let users play it themself. | false | 23,715,822 | 0 | 0 | 0 | 0 | From what I've done, no, you cannot. The best ways imo are as follows:
Making folders (files>images) to make it less desirable to look for them.
(Not sure how well this would work with pygame) but hidden folders might work. I used hidden folders for file writing in python.
Otherwise I think that it wouldn't be so bad if someone were to just play a sound file or look at your artwork, is there a specific problem with it? | 0 | 416 | 0 | 1 | 2014-05-17T20:32:00.000 | python,compilation,pygame,exe,cx-freeze | Compiled my Game made in pygame to .exe. Is there any way to compile all files? | 0 | 1 | 1 | 28,030,394 | 1 |
1 | 0 | so I trying to build project for cocos2d-x. I'm currently at cmd and when I type python android-build.py -p 19 cpp-tests it start making project but then I get error that build failed. Problem is bescause it can't find javac compiler.
"Perhaps JAVA_HOME does not point to the JDk. It is currently set to
"c:/Program Files/Java/jre7"
Problem is bescause in system variables I made new variable called JAVA_HOME and it is pointed to C:\android\Java\jdk1.8.0_05\bin but still I getting that error. What to do guys? | false | 23,716,064 | 0 | 1 | 0 | 0 | You have to point JAVA_HOME to this path:
C:\android\Java\jdk1.8.0_05 | 0 | 90 | 0 | 1 | 2014-05-17T21:04:00.000 | java,android,python,c++ | JAVA_HOME "bug" | 0 | 1 | 1 | 31,828,819 | 1 |
0 | 0 | I am working on my Python project using PySide as my Ui language. My projet is a game which require an internet connection to update the users'score and store in the database.
My problem is how can I store my database in the internet. I mean that all users can access this information when they are connected to an internet (when they are playing my game) and the information/database must be updated all the time.
I am not sure which database is the most appropriate, how to store this information/database in the internet, how to access this information.
I am using Python and PySide.
For the database, I currently use PySide.QtSql .
Thank you for answer(s) or suggestion(s). | false | 23,754,108 | 0 | 0 | 1 | 0 | I'm not familiar with PySide .. but the idea is
you need to build a function that when internet connection is available it should synchronize your local database with online database and in the server-side you need to build a script that can handle requests ( POST / GET ) to receive the scores and send it to database and I suggest MySQL ..
Hope that helps | 0 | 193 | 0 | 0 | 2014-05-20T07:59:00.000 | python,database,sockets,pyside,qtsql | Using Database with Pyside and Socket | 0 | 1 | 1 | 23,754,331 | 1 |
0 | 1 | Current conditions:
C code being rewritten to do almost the same type of simulation every time (learning behavior in mice)
Matlab code being written for every simulation to plot results (2D, potentially 3D graphs)
Here are my goals:
Design GUI (wxPython) that allows me to build a dynamic simulator
GUI also displays results of simulation via OpenGL (or perhaps Matplotlib)
Use a C wrapper (CFFI) to run the simulation and send the results (averages) to OpenGL or Matplotlib
Question:
In order to have this software run as efficiently as possible, it makes sense to me that CFFI should be used to run the simulation...what I'm not sure about is if it would be better to have that FFI instance (or a separate one?) use an OpenGL C binding to do all the graphics stuff and pass the resulting graphs up to the Python layer to display in the GUI, or have CFFI send the averages of the simulations (the data that gets plotted) to variables in the Python level and use PyOpenGL or Matplotlib to plot graphs. | false | 23,819,504 | 0.197375 | 0 | 0 | 1 | It would help to know what the turnaround time for the simulation runs is and how fast you want to display and update graphs. More or less realtime, tens of milliseconds for each? Seconds? Minutes?
If you want to draw graphs, I'd recommend Matplotlib rather than OpenGL. Even hacking the Matplotlib code yourself to make it do exactly what you want will probably still be easier than doing stuff in OpenGL. And Matplotlib also has "XKCD" style graphs :-)
PyOpenGL works fine with wxPython. Most of the grunt work in modern 3D is done by the GPU so it probably won't be worth doing 3D graphics in C rather than Python if you decide to go that route.
Hope this helps. | 0 | 461 | 0 | 1 | 2014-05-23T01:04:00.000 | python,c,opengl,interop,python-cffi | Interoperability advice - Python, C, Matplotlib/OpenGL run-time efficency | 0 | 1 | 1 | 23,861,390 | 1 |
0 | 0 | I am trying to download/install Light Table. I want it to show up in the start menu.
When downloading light table, it shows up as a Zip folder in the TEMP file. I've extracted the files and am unable to get it to show up in the start menu.
Normally the programs I download have an installer that does this automatically. Light Table doesn't seem to have this.
I'm sure I can use it from the TEMP folder, but would really like it in the start menu, program files folder or C drive.
I've only done basic use of PCs (gaming, web browsing, MS Office). | false | 23,846,899 | 0.53705 | 0 | 0 | 3 | It's pretty easy to do.
Unzip to where ever
Move the LightTable directory (from inside LightTableWin) to your Program Files (x86) directory.
2.1 If you are using Windows Explorer, you'll need to start windows explorer as an administrator (found by right clicking the program icon)
open your Program Files (x86)\LightTable directory, right click
and drap the LightTable.exe file into the same directory and select
Create Shortcut
Left Click your short cut and drag it to
your start menu. When it asks if you want to pin it to your start
menu, select yes.
Click on Start, and then click on the light table short cut.
Use Light Table | 1 | 2,589 | 0 | 2 | 2014-05-24T15:45:00.000 | python,windows-7,installation,lighttable | Install Light Table editor on Windows 7 | 0 | 1 | 1 | 29,813,451 | 1 |
0 | 0 | I have searched a lot and I know how to open a directory dialog window.
But what I am looking for is the method to open a directory folder under windows OS, just like you right click one of your local folder and select open.
Any suggestions? | false | 23,859,613 | 0.132549 | 0 | 0 | 4 | You may simply try this:
os.startfile(whatever_valid_filename)
This starts the default OS application for whatever_valid_filename, meaning Explorer for a folder name, default notepad for a .txt file, etc. | 0 | 21,145 | 0 | 4 | 2014-05-25T20:22:00.000 | python,pyqt,pyqt4 | PyQt - How to open a directory folder? | 0 | 1 | 6 | 41,981,238 | 1 |
0 | 0 | I'm writing a mediaplayer-gui fitting some needs of a medialibrary containing classical music only.
Language is python3/tkinter.
One backend is gstreamer1.0, playbin (seems to be the only one, playing gapless).
When playbin gets the uri of a file with 5.0 channels
(FRONT_LEFT,FRONT_RIGHT,FRONT_CENTER,REAR_LEFT,REAR_RIGHT)
it gives following warning:
** (python3:13745): WARNING **: Unpositioned audio channel position flag set but channel positions present
and plays the file downmixed to stereo.
5.0 is most common in classical-music media(LFE is mostly unwanted).
Which gstreamer-object is the one, i can tell about channel-layout and what signal do i have to connect to, to get that object?
Additional info:
5.1 gives the same warning, but plays without downmixing;
5.0 using gstplay-1.0 from commandline gives warning & downmixing;
using gst123 based on gstreamer0.1 plays everything right | false | 23,884,156 | 0.197375 | 0 | 0 | 1 | I'd suggest to file a bug and ideally make your test files available.
If you want to track this down yourself take a look at the GST_DEBUG="*:3" ./your-app output to see which element is emitting the warning. | 0 | 193 | 0 | 0 | 2014-05-27T08:08:00.000 | python,gstreamer | how to make playbin of gstreamer1.0 playing multichannel-audio 5.0 playing without downmixing to stereo | 0 | 1 | 1 | 23,921,536 | 1 |
0 | 0 | I have a Kivy-based Python project that I'm trying to build. It uses the NavigationDrawer component from Kivy Garden, through an import:
from kivy.garden.navigationdrawer import NavigationDrawer
I have a PyInstaller spec file for it which builds a distributable version. This version works well on my machine, but unfortunately not on other machines. Running the interpreter in the 'dist' version with the -v switch, it appears that when I run the distributable on my machine, the navigationdrawer component is not actually coming from inside my build folder. All the other imports show something like:
import kivy.graphics.gl_instructions # dynamically loaded from C:\Users\me\myapp\dist\RACECA~1\kivy.graphics.gl_instructions.pyd
But the navigationdrawer import says:
import kivy.garden.navigationdrawer
"""directory C:\Users\me\.kivy\garden\garden.navigationdrawer
C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.pyc matches C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.py
import kivy.garden.navigationdrawer # precompiled from C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.pyc"""
But noo! I don't want you to import them from c:\users. I want them to get nicely copied into my dist folder like all the other imports. I've tried adding c:\users\me to PyInstaller's pathex, the system PATH and PYTHONPATH without any joy. Anyone have any ideas? | false | 24,048,350 | 0 | 0 | 0 | 0 | I had a similar issue with garden modules. When I install like the following:
start cmd /C "garden install --kivy roulettescroll"
start cmd /C "garden install --kivy roulette"
start cmd /C "garden install --kivy tickline"
start cmd /C "garden install --kivy datetimepicker"
I add PyInstaller ... --hidden-import=kivy.garden.tickline --hidden-import=kivy.garden.roulette --hidden-import=kivy.garden.roulettescroll --hidden-import=kivy.garden.datetimepicker ...
I'm able to install and have no problems with Python picking up the modules. Unfortunately, the datetimepicker shows up as white rectangles. I have no idea what I might be missing.. But atleast I got past the import issue. | 1 | 2,433 | 0 | 4 | 2014-06-04T22:00:00.000 | python,kivy,pyinstaller | Kivy Garden in PyInstaller - stuck trying to trace import | 0 | 3 | 4 | 39,481,035 | 1 |
0 | 0 | I have a Kivy-based Python project that I'm trying to build. It uses the NavigationDrawer component from Kivy Garden, through an import:
from kivy.garden.navigationdrawer import NavigationDrawer
I have a PyInstaller spec file for it which builds a distributable version. This version works well on my machine, but unfortunately not on other machines. Running the interpreter in the 'dist' version with the -v switch, it appears that when I run the distributable on my machine, the navigationdrawer component is not actually coming from inside my build folder. All the other imports show something like:
import kivy.graphics.gl_instructions # dynamically loaded from C:\Users\me\myapp\dist\RACECA~1\kivy.graphics.gl_instructions.pyd
But the navigationdrawer import says:
import kivy.garden.navigationdrawer
"""directory C:\Users\me\.kivy\garden\garden.navigationdrawer
C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.pyc matches C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.py
import kivy.garden.navigationdrawer # precompiled from C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.pyc"""
But noo! I don't want you to import them from c:\users. I want them to get nicely copied into my dist folder like all the other imports. I've tried adding c:\users\me to PyInstaller's pathex, the system PATH and PYTHONPATH without any joy. Anyone have any ideas? | false | 24,048,350 | 0.099668 | 0 | 0 | 2 | You could just copy the navigationdrawer code from C:\Users\me\.kivy\garden\garden.navigationdrawer to your app directory, call the folder 'navigationdrawer' and replace the import with from navigationdrawer import NavigationDrawer.
It's not quite the 'right' way to do it (there's probably some way to make pyinstaller copy it in), but it should work fine. | 1 | 2,433 | 0 | 4 | 2014-06-04T22:00:00.000 | python,kivy,pyinstaller | Kivy Garden in PyInstaller - stuck trying to trace import | 0 | 3 | 4 | 24,048,458 | 1 |
0 | 0 | I have a Kivy-based Python project that I'm trying to build. It uses the NavigationDrawer component from Kivy Garden, through an import:
from kivy.garden.navigationdrawer import NavigationDrawer
I have a PyInstaller spec file for it which builds a distributable version. This version works well on my machine, but unfortunately not on other machines. Running the interpreter in the 'dist' version with the -v switch, it appears that when I run the distributable on my machine, the navigationdrawer component is not actually coming from inside my build folder. All the other imports show something like:
import kivy.graphics.gl_instructions # dynamically loaded from C:\Users\me\myapp\dist\RACECA~1\kivy.graphics.gl_instructions.pyd
But the navigationdrawer import says:
import kivy.garden.navigationdrawer
"""directory C:\Users\me\.kivy\garden\garden.navigationdrawer
C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.pyc matches C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.py
import kivy.garden.navigationdrawer # precompiled from C:\Users\me\.kivy\garden\garden.navigationdrawer\__init__.pyc"""
But noo! I don't want you to import them from c:\users. I want them to get nicely copied into my dist folder like all the other imports. I've tried adding c:\users\me to PyInstaller's pathex, the system PATH and PYTHONPATH without any joy. Anyone have any ideas? | false | 24,048,350 | -0.049958 | 0 | 0 | -1 | Go to your python site packages there is a folder named garden, look in __init__.py. There is a explanation how to install navigationdrawer. | 1 | 2,433 | 0 | 4 | 2014-06-04T22:00:00.000 | python,kivy,pyinstaller | Kivy Garden in PyInstaller - stuck trying to trace import | 0 | 3 | 4 | 35,244,089 | 1 |
0 | 0 | I have a database table (created using the SQLite3 library) and would like to be able to open a new window (in a program that I am writing) which will simply display the contents of the table (*.db) with a scroll bar to the user (perhaps on a grid like you would find in a spreadsheet).
Are there any easy ways of achieving this? | true | 24,118,765 | 1.2 | 0 | 0 | 1 | I think you would use
.grid() in a Frame or
multiple Listboxes with as many scrollbars as you like. | 0 | 1,409 | 0 | 0 | 2014-06-09T10:53:00.000 | python,sqlite,tkinter | Is there a tkinter widget to easily display a table (SQLite) in a window (canvas)? | 0 | 1 | 1 | 24,123,191 | 1 |
0 | 0 | I am currently working on a project to import a Matlab program to python for integration into ImageJ as a plugin. The program contains Mex files and the source code was written in C++. Is there a way to call the C++ functions without having to rewrite them in python. Thanks!!! | true | 24,153,503 | 1.2 | 1 | 0 | 1 | If you can build your program as a shared library, then you can use the ctypes foreign-function interface to call your functions.
This is often less work (and less complex) than wrapping the functions with Cython or writing your own C-API extension, but it is also more limited in what you can do. Therefore, I recommend starting with ctypes, and moving up to Cython if you find that ctypes doesn't suit your needs.
However, for simple libraries, ctypes will do just fine (I use it a lot). | 0 | 1,339 | 0 | 0 | 2014-06-11T01:54:00.000 | python,c,matlab,mex | Call C/C++ code from Python | 0 | 1 | 2 | 24,154,260 | 1 |
0 | 0 | I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox.
Now i need to pass a shared object to python script as an argument from my app.
what type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script.
thanks | false | 24,237,335 | 0.099668 | 0 | 0 | 1 | Since python is running as another process. This is no way for python to access object in c# directly since process isolation.
A way of marshal and un-marshal should be included to communicate between processes.
There are many way to communicate between processes. Share memory, file, TCP and so on. | 1 | 912 | 0 | 3 | 2014-06-16T05:54:00.000 | c#,python,.net,share,shared-objects | shared object in C# to be used in python script | 0 | 2 | 2 | 24,281,523 | 1 |
0 | 0 | I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox.
Now i need to pass a shared object to python script as an argument from my app.
what type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script.
thanks | false | 24,237,335 | 0.099668 | 0 | 0 | 1 | 5.4. Extending Embedded Python
will help you to access the application object.
In this case both application and python running in single process. | 1 | 912 | 0 | 3 | 2014-06-16T05:54:00.000 | c#,python,.net,share,shared-objects | shared object in C# to be used in python script | 0 | 2 | 2 | 32,651,105 | 1 |
0 | 0 | Pretty self-explanatory from the title. I'm using PyQt4 to crawl pages and I occasionally get a SegFault error.
The overall program seems to still be working regardless though, so all I want to do is prevent that "Segmentation Fault (core dumped)" error from being shown on the console. How is this done? | true | 24,268,634 | 1.2 | 0 | 0 | 2 | Segmentation Fault is an system error, which occurs when your program tries to access wrong memory address. It is internal program problem and you cannot continue process. It could be possible, but believe me, you should not. So, you should fix it.
To fix it, you should dig into Qt internals, but I'd like to suggest you to install fresh library version and make sure you have latest packages. | 1 | 205 | 0 | 1 | 2014-06-17T16:11:00.000 | python | "Segmentation Fault" being thrown by third party package. How to prevent it from displaying on console? | 0 | 1 | 1 | 24,268,970 | 1 |
0 | 0 | I've been trying to add separator lines between rows in my grid. I tried using wx.Menu() with the AppendSeparator() method, however the wx grid can't add objects of type Menu. Is there any other way? | true | 24,287,228 | 1.2 | 0 | 0 | 1 | This is not supported by the grid widget. You could size a column or row such that it is skinnier than usual and change all the cells in that row or column to have a different background color. You might also be able to utilize a custom label renderer or cell renderer. See the wxPython demo for examples. | 0 | 160 | 0 | 0 | 2014-06-18T13:43:00.000 | python-2.7,wxpython | How do I add a separator in a grid in wxPython? | 0 | 1 | 1 | 24,311,759 | 1 |
0 | 0 | I am having this error flood my terminal and make it impossible to debug. Is there a way to silence this warning? This error only generated when I included a scrollToBottom() on my TableWidget. | false | 24,289,418 | 0 | 0 | 0 | 0 | It would be much better if some of your actual code would have been available.
The reason you are seeing this is that you are using a different type of threading than QThreads . That is in general not advisable, but it is not illegal. There are three things that you will have to take care
All calls should end up being executed from calls within a QThreads object
All data passed through the signal-slots mechanism should be made such that there are no references/pointers to objects owned from a non-QThread.
Setup connections between object that receive call from non-QThreads to emit signal that are received with either Qt::QueuedConnection or Qt::BlockingQueuedConnection connection type. | 1 | 7,241 | 0 | 3 | 2014-06-18T15:23:00.000 | python,qt,error-handling,pyqt,suppress-warnings | How to suppress warning QPixmap: It is not safe to use pixmaps outside the GUI thread | 0 | 2 | 3 | 33,542,567 | 1 |
0 | 0 | I am having this error flood my terminal and make it impossible to debug. Is there a way to silence this warning? This error only generated when I included a scrollToBottom() on my TableWidget. | false | 24,289,418 | 0 | 0 | 0 | 0 | You should better design your code to avoid displaying this message. If you created the pixmap in another thread and "use" it in the GUI thread this might work now, tomorrow or forever ... or will not. Don't do that.
You cannot suppress the output of this warning without changing the Qt sources or installing a message handler. | 1 | 7,241 | 0 | 3 | 2014-06-18T15:23:00.000 | python,qt,error-handling,pyqt,suppress-warnings | How to suppress warning QPixmap: It is not safe to use pixmaps outside the GUI thread | 0 | 2 | 3 | 24,291,464 | 1 |
0 | 0 | I've been looking for ways to make a GUI with a .py file, and have so far only found frameworks and modules like Tkinter. However, my ultimate goal is for this code to run on a lot of computers that don't necessarily have these modules installed. The machines are only guaranteed to have Python on them. Does anyone know a way to make a GUI under these restrictions? | true | 24,295,681 | 1.2 | 0 | 0 | 3 | The best way to do this would be to ship your application with those modules as a part of it; the user's computer doesn't need to have the GUI framework installed if you provide it.
What you're asking would essentially require you to write an entire GUI framework, which would give a result that would be similar or worse - with a LOT more work. | 1 | 57 | 0 | 1 | 2014-06-18T21:57:00.000 | python,user-interface | Can I make a GUI with Python without any extraneous software? | 0 | 1 | 1 | 24,295,727 | 1 |
0 | 0 | I'm packaging a GUI app for MacOS with Pyinstaller, using --windowed flag. Is it possible to package it so that it would show a console in addition to the GUI? When I tried to set console=True, the GUI part fails.
In other words, when I start the App from the terminal by typing "open My.App/Contents/MacOS/myapp", then I do get both GUI and console. I'd like to get similar behaviour by just double-clicking on the App without starting the terminal. Is there a way to do it? | false | 24,333,323 | 0 | 0 | 0 | 0 | while you create application don't add those options
--windowed and --noconsole | 1 | 425 | 1 | 6 | 2014-06-20T18:15:00.000 | python,macos,pyinstaller | How to package a Mac OS app with Pyinstaller that shows both a console and a GUI? | 0 | 1 | 1 | 53,956,162 | 1 |
0 | 0 | It seems to me the buffer protocol is more for exposing Python buffer to C.
I couldn't find a way to create a bytes object using existing buffer without copying in C.
Basically what I want is to implement something similar to PyBytes_FromStringAndSize() but without copying, and with a callback to free the buffer when the object is released. I don't know how big the buffer is before I receive the buffer returned from a C API. So creating bytes object in Python first and later fill it in is not an option.
I also looked into memoryview, PyMemoryView_FromMemory() doesn't copy but there is no way to pass a callback to free my buffer. And I'm not suse Python lib (e.g. Psycopg) can use memoryview object or not.
Do I have to create my own object to achieve these 2 requirements? Any other shortcut?
If I have to, how can I make sure this object works same as bytes so I can pass it to Python lib safely?
Thanks. | false | 24,336,655 | 0.197375 | 0 | 0 | 1 | The only way to do this is to create a new object with PyBufferProcs* PyTypeObject.tp_as_buffer. I checked cpython source code thoroughly, as of 3.4.1, there is no out-of-box (so to speak) solution. | 0 | 444 | 0 | 7 | 2014-06-20T22:38:00.000 | python-3.x,python-c-api,python-c-extension | python c-api: create bytes using existing buffer without copying | 0 | 1 | 1 | 26,024,351 | 1 |
0 | 0 | I'm working on a project that requires user generated images to be applied to various 3D models (mugs, t-shirts etc). I've explored numerous applications, (Pyglet, Blender, Panda to name a few), and am looking for ideas / guidance as to the best approach.
Appears to me that the world of 3D modelling has quite a steep learning curve (looking at you GL), just looking to invest my time wisely.
Thoughts? | false | 24,367,286 | 0 | 0 | 0 | 0 | In the case where you're interested in replacing textures on-the-fly, you should render your objects as UV maps.
UV maps specify the pixel offset within the texture so that once a texture is chosen, it is a simple process of table lookup for filling in the texture.
You might consider rendering at double the resolution and after applying reduce the image size. This will anti-alias any discontinuities. | 0 | 87 | 0 | 2 | 2014-06-23T13:32:00.000 | python,image-processing,3d | Looking for advice on applying textures to 3D models at run time | 0 | 1 | 1 | 24,371,384 | 1 |
0 | 0 | I am learning wxpython and have a question.
When I create a treectrl within framework and call framework.show(), the first item in the treectrl is automatically selected (i.e., EVT_TREE_SEL_CHANGED event is fired). However, when I create a treectrl in a panel, add the panel to a notebook and add the notebook to framework, the EVT_TREE_SEL_CHANGED event is not fired when the framework.show() is called. Instead, when I select an item in the treecontrol later after the initial rendering, two EVT_TREE_SEL_CHANGED are fired (one for the first item which is supposed to be fired during the initial rendering and the other one for the selected item).
panel.SetFocus() in the bottom of framework.__init__() fix this problem -- i.e., fires EVT_TREE_SEL_CHANGED to select the first item during the initial rendering. But, I wonder why this is happening. Does anybody know why EVT_TREE_SEL_CHANGED is blocked in the initial rendering when the tree control is contained in the panel of notebook? | false | 24,442,775 | 0 | 0 | 0 | 0 | I don't know why exactly does this happen but this looks like a bug in wxWidgets. In practice, this means that it you shouldn't rely on this behaviour because it might (and in fact I'm pretty sure it does) behave differently under other platforms and also could change in future wxWidgets versions. | 0 | 291 | 0 | 1 | 2014-06-27T01:42:00.000 | python,wxpython,wxwidgets | wxpython: EVT_TREE_SEL_CHANGED event in treectrl in notebook when created | 0 | 1 | 1 | 24,454,132 | 1 |
0 | 0 | My goal is to create a window that has a variable level of transparency and no standard border. On top of that area I would like to display opaque items, especially text, that might need to be made transparent. I have tried using SetTransparency methods, SetBackgroundColor and wx.TRANSPARENT_WINDOW styles but haven't had any luck in essentially keeping the children transparency level independent from the parent window's. I have started looking into the graphic and draw methods but not sure if this result is even possible to implement in wxPython. Should I be using a different tool or can this be achieved in wxPython? | true | 24,457,479 | 1.2 | 0 | 0 | 1 | wxPython does not support this behavior. You might be able to fake it by creating lots of custom widgets or by drawing everything, but it will be a lot of work. You would be better off switching to a different toolkit that has this sort of thing builtin. wxPython is for developers that want to make applications that look native on the target OS. | 0 | 328 | 0 | 0 | 2014-06-27T17:18:00.000 | wxpython | Is it possible to have a transparent window while having opaque children? | 0 | 1 | 1 | 24,457,910 | 1 |
0 | 0 | Hi I am trying to make a punny cookie clicker type game called py clicker and made an invisible circle over the sprite which is a pie. How do I detect if the mouse is within the circle so when the user clicks it checks if it is in the circle and adds one to the counter? | false | 24,473,156 | 0 | 0 | 0 | 0 | you can use the graphics library and use the method called getMouse. | 0 | 127 | 0 | 0 | 2014-06-29T04:27:00.000 | python,pygame | Python 2.7.7/Pygame - How to detect if the mouse is within a circle? | 0 | 1 | 3 | 24,473,291 | 1 |
0 | 0 | How the hell to install tkinter on to my PC ?
I tried for week to install it. I can not figure it out. Please, Help.
How does it work ? Is there a site you install it from or what ? | false | 24,499,602 | 0 | 0 | 0 | 0 | Just change your code to
from tkinter import *
In python3, the issue is with capitalization, so you should use tkinter instead of Tkinter. | 0 | 10,084 | 0 | 3 | 2014-06-30T21:59:00.000 | python,tkinter,installation | How to install Tkinter? | 0 | 1 | 4 | 57,996,033 | 1 |
0 | 0 | I'm considering attempting a game built using Panda3D where no objects are built using a 3D editor. It would all be made and rendered using geometric functions. This includes multiple characters running around, spells being cast and buildings and other objects being around.
How viable of an idea is this? Would rendering all of that in real-time be too inefficient?
I have a very vague idea myself of what the game will consist of at this point or else I'd give more details, but I'm really just wondering if the general idea is possible. | false | 24,523,468 | 0 | 0 | 0 | 0 | Have a look at other games made with Panda3D. see the tutorials, demos, etc. That will give you a good overview of what can be possibly made. Check for the keyword technologies that you need - SSAO, Skeletal-Animation, Physics, etc.
In general, you might want to detalise your idea and see how other games implement parts of it. If there are some unique things that nowhere to be found - then ask about how to make them. Otherwise they are certainly viable (as someone already made them)
Without much more info in the original question, the answer can be only this detailed. | 0 | 344 | 0 | 0 | 2014-07-02T05:27:00.000 | python,3d,render,panda3d | Real-time Geometry Rendering with Panda3D -- Efficient? | 0 | 1 | 1 | 25,160,655 | 1 |
0 | 0 | I am writing an app in kivy which does cpu-heavy calculations at launch. I want the app to display what it's doing at the moment along with the progress, however, since the main loop is not reached yet, it just displays empty white screen until it finishes working. Can I force kivy to update the interface?
Basically I'm looking for kivy's equivalent of Tkinter's root.update()
I could create a workaround by defining a series of functions with each calling the next one through Clock.schedule_once(nextFunction, 1), but that would be very sloppy.
Thanks in advance. | false | 24,529,197 | 0.197375 | 0 | 0 | 1 | Leaving aside the question of whether you should be using threading or something instead (which possibly you should), the answer is just that you should move your cpu calculations to somewhere else. Display something simple initially (i.e. returning a simple widget from your build method), then do the calculations after that, such as by clock scheduling them.
Your calculations will still block the gui in this case. You can work around this by doing them in a thread or by manually breaking them up into small pieces that can be sequentially scheduled.
It might be possible to update the gui by manually calling something like Clock.tick(), but I'm not sure if this will work right, and even if so it won't be able to display graphics before they have been initialised. | 0 | 2,011 | 0 | 1 | 2014-07-02T10:47:00.000 | python,kivy | Force update GUI in kivy | 0 | 1 | 1 | 24,530,629 | 1 |
0 | 0 | I have code as follows
log = wx.TextCtrl(panel, wx.ID_ANY, size=(300,100),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL|wx.TE_DONTWRAP)
I'm writing logs into this box by redirecting stdout.
How do I make the cursor dissappear for the TextCtrl because it appends logs based on the position of the cursor right now. I dont want to give the user the privilage to place the cursor at a particular spot in the box basically | false | 24,538,053 | 0 | 0 | 0 | 0 | But if you use log.Disable, the scrollbar won't work | 0 | 3,622 | 0 | 1 | 2014-07-02T18:05:00.000 | python,wxpython | Disable cursor in TextCtrl - wxPython | 0 | 1 | 5 | 44,200,976 | 1 |
0 | 0 | I'm using glutBitmapCharacter of pyOpenGL in Python, but the only fonts I can choose to use are helvetica and times_new_roman. Is it possible to add more fonts? | false | 24,563,337 | 0 | 0 | 0 | 0 | Not without modifying your GLUT implementation to add additional enums and font bitmaps. | 0 | 571 | 0 | 0 | 2014-07-03T21:09:00.000 | python,opengl,text,fonts,pyopengl | python more fonts in glut (glutBitmapCharacter) | 0 | 1 | 1 | 24,563,549 | 1 |
0 | 0 | Basically if I drag a cell I can size it to whatever size I want. Is there functionality in wxPython where cells expand automatically to fit the size of the text inside of them? | true | 24,609,197 | 1.2 | 0 | 0 | 1 | The Grid class has AutoSizeColumn/AutoSizeRow and AutoSizeColumns/AutoSizeRows methods that do a fairly good job of generically resizing rows or cols to be large enough for the contents of the row or col. They can be fairly expensive operations for large grids however, so they should be used with care. | 0 | 2,930 | 0 | 1 | 2014-07-07T11:09:00.000 | python,wxpython,wxgrid | How to make text fit in cells in a wxPython grid? | 0 | 1 | 3 | 24,620,168 | 1 |
0 | 0 | I am planning on using IronPython to develop a GUI interface for some python code. Do I need to know any other programming languages other than python. Also if not are there any other GUI packages/addon's to python that only use python to implement and get the final product working? | true | 24,635,660 | 1.2 | 1 | 0 | 2 | You don't need to know any other languages - modulo a few implementation differences, Python is Python is Python. You will, however, need to know the Microsoft windowing library, with which I believe you will have to interface to build a GUI. | 1 | 134 | 0 | 2 | 2014-07-08T15:20:00.000 | python,ironpython | Does IronPython just use Python or to use IronPython do I need to know other programming languages other than python? | 0 | 1 | 1 | 24,636,635 | 1 |
0 | 0 | I have used img2py to convert an image into a .py file. But how to use that converted file in pygame. Is there any specific code for it? | false | 24,639,577 | 0.379949 | 0 | 0 | 2 | The PyEmbeddedImage class has a GetData method (or Data property) that can be used to fetch the raw data of the embedded image, in PNG format. | 1 | 748 | 0 | 1 | 2014-07-08T18:52:00.000 | wxpython,pygame | How to use/decompress the file made by img2py | 0 | 1 | 1 | 24,644,067 | 1 |
0 | 0 | I have a Python code that needs to be able to execute a C++ code. I'm new to the idea of creating libraries but from what I have learned so far I need to know whether I need to use static or dynamic linking.
I have read up on the pros and cons of both but there is a lot of jargon thrown around that I do not understand yet and since I need to do this ASAP I was wondering if some light can be shed on this from somebody who can explain it simply to me.
So here's the situation. My C++ code generates some text files that have data. My Python code then uses those text files to plot the data. As a starter, I need to be able to run the C++ code directly from Python. Is DLL more suitable than SL? Or am I barking up the completely wrong tree?
Extra: is it possible to edit variables in my C++ code, compile it and execute it, all directly from Python? | true | 24,650,785 | 1.2 | 1 | 0 | 5 | It depends on your desired deployment. If you use dynamic linking will need to carefully manage the libraries (.so, .dll) on your path and ensure that the correct version is loaded. This can be helped if you include the version number in the filename, but then that has its own problems (security... displaying version numbers of your code is a bad idea).
Another benefit is that you can swap your library functionality without a re-compile as long as the interface does not change.
Statically linking is conceptually simpler and practically simpler. You only have to deploy one artefact (an .exe for example). I recommend you start with that until you need to move to the more complicated shared library setup.
Edit: I don't understand your "extra credit" question. What do you mean by "edit values"? If you mean can you modify variables that were declared in your C++ code, then yes you can as long as you use part of the public interface to do it.
BTW this advice is for the general decision. If you are linking from Python to C/C++ I think you need to use a shared library. Not sure as I haven't done it myself.
EDIT: To expand on "public interface". When you create a C++ library of whatever kind, you specify what functions are available to outside classes (look up how to to that). This is what I mean by public interface. Parts of your library are inaccessible but others (that you specify) are able to be called from client code (i.e. your python script). This allows you to modify the values that are stored in memory.
If you DO mean that you want to edit the actual C++ code from within your python I would suggest that you should re-design your application. You should be able to customise the run-time behaviour of your C++ library by providing the appropriate configuration.
If you give a solid example of what you mean by that we'll be able to give you better advice. | 0 | 2,081 | 0 | 3 | 2014-07-09T10:07:00.000 | python,c++,dll,static-libraries | Advise needed for Static vs Dynamic linking | 0 | 1 | 3 | 24,650,884 | 1 |
0 | 0 | Alright so this is a specific question about data transfer using different windows in pyqt4. Basically I have 3 windows, each with its own class definition, that I have designed for a project but I'm confused about how to properly arrange these windows.
Ideal Functionality:
Let's say I have 3 windows; A, B, and C. Window A gives me two lists. When I click a button in Window A, window B pops up and gets me a number. After it gives me this number I want window C to open and window B to close but I want window C to have the two lists and the number.
Problems I have:
Currently I make a function in the class for window A to open window B and once I get the number from window B, then window C is created with the information, but it closes since I close window B. Previously I tried keeping window A opening window B and C but it opens the windows at the same time but I need window B to open for its data to then create window C. | true | 24,708,697 | 1.2 | 0 | 0 | 0 | C have to be child of A than you can close B. B can call function in parent A to open C and then B can close itself. | 0 | 33 | 0 | 0 | 2014-07-12T01:20:00.000 | python-3.x,pyqt4 | Controlling Windows/Information PYQT4 | 0 | 1 | 1 | 24,714,113 | 1 |
0 | 0 | Hello I am developing easy space invaders clone game and i need to figure out a way how to detect collision of the bullet and the alien when i shoot. Any suggestions ? Thanks | true | 24,713,228 | 1.2 | 0 | 0 | 1 | Use Pygame in place of Tkinter (eventually in place of Canvas) - there are functions to check collisions.
To check collision you have to get position both elements and check distance between them:
a2 + b2 = c2
a = x1 - x2 , b = y1 - y2 , c = distance between objects A(x1,y1) and B(x2,y2)
If distance is smaller then some value then you have collision - distance doesn't have to be zero to have collision. This way you check collision in circle around object.
But you can check collision in square area around the object - it wil be easer for you to calculate it
Object A (x1,y1) has square area x1-10 ... x1+10, y1-10 ... y1+10. You have to check whether object B (x2,y2) is in that square. | 0 | 6,110 | 0 | 0 | 2014-07-12T13:04:00.000 | python,tkinter | How to detect collisions of two canvas object Tkinter | 0 | 1 | 2 | 24,713,651 | 1 |
1 | 0 | I've got a text view and a web view, each inside a scrolled window of their own and I'm trying to achieve synchronized scrolling between the two but I can't seem to get it to work.
The web view is basically taking the text from the text view and rendering it as marked up HTML via webview.load_html_string(). I think the problem could be the delay in loading the HTML as every time the web view is refreshed it is scrolled back to the very start.
Right now I call a function every time the content of the text view is changed and then modify the vadjustment.value of the scrolled window containing the web view.
But this doesn't work. Is it because of the delay? I can't think of any way to solve this issue. | false | 24,718,142 | 0 | 0 | 0 | 0 | why do you want sync those scrollbars? You can achieve this by using the same Gtk.Adjustment (number of pages sets to 0).
I haven't use much of webkit but it essentialy a widget. so maybe a workaround would be disconnect a signal "value-changed" from Gtk.Adjustment until "load-status" signal from WebKitView reached Webkit.LoadStatus.FINISHED (if that's the correct syntax).
If that doesn't work, maybe you use WebKitView.move_cursor () (if i remember the function properly) based on Gtk.Adjustment on your text view (we use 2 adjustments this time) | 0 | 221 | 0 | 0 | 2014-07-12T23:15:00.000 | python,webkit,gtk,pygtk | pygtk TextView and WebKit.WebView synchronized scrolling | 0 | 1 | 1 | 24,722,441 | 1 |
0 | 0 | When I open a site with the webkit webview, the entire window resizes to fit the page not allowing scrollbars. The window's height exceeds my screen height. Also, when a webview is in the window, I can resize the window outward, but I can't resize it inward. A webview won't show at all in a VBox if I do: MyVBox.pack_start(MyWebview, True, True, 0) | true | 24,729,658 | 1.2 | 0 | 0 | 0 | you have to put the Gtk.WebKitView inside a Gtk.ScrolledWindow. since it implement a Gtk.Scrollable you need not using a Gtk.Viewport. and put the window inside your Gtk.Box | 0 | 118 | 0 | 0 | 2014-07-14T04:46:00.000 | python,webkit,gtk,pygtk,webkitgtk | PyWebkitGTK loads a website fully vertical into window and will not resize inward | 0 | 1 | 1 | 24,751,754 | 1 |
0 | 0 | I'm drawing a map of a real world floor with dimensions roughly 100,000mm x 200,000mm.
My initial code contained a function that converted any millimeter based position to screen positioning using the window size of my pygame map, but after digging through some of the pygame functions, I realized that the pygame transformation functions are quite powerful.
Instead, I'd like to create a surface that is 1:1 scale of real world and then scale it right before i blit it to the screen.
Is this the right way to be doing this? I get an error that says Width or Height too large. Is this a limit of pygame? | false | 24,743,758 | 0.197375 | 0 | 0 | 2 | I dont fully understand your question, but to attempt to answer it here is the following.
No you should not fully draw to the screen then scale it. This is the wrong approach. You should tile very large surfaces and only draw the relevant tiles. If you need a very large view, you should use a scaled down image (pre-scaled). Probably because the amount of memory required to draw an extremely large surface is prohibitive, and scaling it will be slow.
Convert the coordinates to the tiled version using some sort of global matrix that scales everything to the size you expect. So you should also filter out sprites that are not visible by testing their inclusion inside the bounding box of your view port. Keep track of your view port position. You will be able to calculate where in the view port each sprite should be located based on its "world" coordinates. | 0 | 1,634 | 0 | 1 | 2014-07-14T18:57:00.000 | python,graphics,pygame | Pygame Large Surfaces | 0 | 2 | 2 | 24,744,048 | 1 |
0 | 0 | I'm drawing a map of a real world floor with dimensions roughly 100,000mm x 200,000mm.
My initial code contained a function that converted any millimeter based position to screen positioning using the window size of my pygame map, but after digging through some of the pygame functions, I realized that the pygame transformation functions are quite powerful.
Instead, I'd like to create a surface that is 1:1 scale of real world and then scale it right before i blit it to the screen.
Is this the right way to be doing this? I get an error that says Width or Height too large. Is this a limit of pygame? | false | 24,743,758 | 0 | 0 | 0 | 0 | If your map is not dynamic, I would suggest draw a map outside the game and load it in game.
If you plan on converting the game environment into a map, It might be difficult for a large environment. 100,000mm x 200,000mm is a very large area when converting into a pixels. I would suggest you to scale it down before loading.
As for scaling in-game, you can use pygame.transform.rotozoom or pygame.transform.smoothscale.
Also like the first answer mentions, scaling can take significant memory and time for very large images. Scaling a very large image to a very small image can make the image incomprehensible. | 0 | 1,634 | 0 | 1 | 2014-07-14T18:57:00.000 | python,graphics,pygame | Pygame Large Surfaces | 0 | 2 | 2 | 24,744,442 | 1 |
0 | 0 | I am trying to visualize a Control Flow Graph in Python using pyqtgraph. I have the following two problems.
How can I visualize the edges with a direction?
How can I visualize a self edge?
I tried looking into the documentation, but couldn't find. Obviously, I didn't get time to read it all! | false | 24,760,322 | 0.099668 | 0 | 0 | 1 | While pyqtgraph is awesome, for my use case I found a much better tool to do this.
graphviz is a nice tool to develop Control Flow Graphs quite conveniently, and has a large number of features for this particular problem. | 0 | 375 | 0 | 0 | 2014-07-15T14:03:00.000 | python,pyqtgraph | Edges with Direction in pyqtgraph GraphItem | 0 | 2 | 2 | 25,269,345 | 1 |
0 | 0 | I am trying to visualize a Control Flow Graph in Python using pyqtgraph. I have the following two problems.
How can I visualize the edges with a direction?
How can I visualize a self edge?
I tried looking into the documentation, but couldn't find. Obviously, I didn't get time to read it all! | true | 24,760,322 | 1.2 | 0 | 0 | 0 | For direction, you might add a pg.ArrowItem at the end of each line (although this could have poor performance for large networks), and for self connections, QtGui.QGraphicsEllipseItem combined with an arrow. | 0 | 375 | 0 | 0 | 2014-07-15T14:03:00.000 | python,pyqtgraph | Edges with Direction in pyqtgraph GraphItem | 0 | 2 | 2 | 24,763,543 | 1 |
0 | 0 | No i don't ask about spritesheets.
I'm working on a game in pygame and I want to know if it's possible to divide sprite into parts like body parts and then use it in collision-detection with pygame.sprite.groupcollide? | true | 24,763,949 | 1.2 | 0 | 0 | 2 | The default Sprite class has no notion of separate parts of a sprite; the whole thing is assigned a single bounding box. If you plan on using pygame.sprite.groupcollide it seems like you don't want an individual sprite anyway, you want them packaged together in their own group. Keep in mind that the pygame.sprite.Group.add method can take either a single sprite OR an iterable of sprites. So you can nest sprite groups if necessary. | 1 | 357 | 0 | 3 | 2014-07-15T16:55:00.000 | python,pygame,collision-detection,sprite | How to divide sprite into smaller parts in pygame? | 0 | 1 | 1 | 24,764,544 | 1 |
0 | 0 | My question is about QDial. It can make the full tour around. When the value is 0 it jumps to 100 and if the value is 100 and you turn it a little more it passes to 0 suddenly.
How can I disable this? | false | 24,776,767 | 0.066568 | 0 | 0 | 1 | Actually @Trilarion , setWrapping to false does not fix his problem.
The Dial still jumps from end to beginning and vice-versa. This is not cool in some applications.
The only solution, I believe, is to hardly not allowing the Dial to do this in a slot. For example, in value changed. Considering you stored the previous value, you can prevent the user from jumping with the dial around by setting the value again. | 0 | 351 | 0 | 1 | 2014-07-16T09:12:00.000 | python,qt,slider,pyqt,limit | QDial disabling full tour | 0 | 1 | 3 | 34,220,799 | 1 |
0 | 0 | I have terrible doubts regarding python config file approach.
I am creating a program with a GUI (PyQt). The program loads some settings from a .cfg file using the configparser module. And the user can edit these settings from the GUI with the user preferences widget. When the preferences widget is closed the .cfg file is saved but I don't know how to update the rest of the program using the updated settings values.
I will try to explain with an example:
I launch the program. It create a ConfigParser() named config and read settings.cfg.
The program retrieve the value of the option 'clock_speed' (let's say it is 5) from config and set clkSpd = 5.
I click on Edit -> Preferences and change the clock speed via a QSpinBox to 8.
I close the Preferences windget, settings.cfg is saved, the value of the option 'clock_speed' is now 8.
BUT in its module, clkSpd is still 5.
I know I can just load the settings, edit them, save them and reload all settings each time I close the Preferences window. It's simple but not very beautiful.
Is there a classic and effficiant approach for config files in read/write mode ?
Thanks by advance. | false | 24,785,121 | 0 | 0 | 0 | 0 | Updating the state of your application may not be a trivial thing if you are somewhere in the middle. Just an example:
Your app = A car
You launch your app = You start your car
You set in the preferences the variable type_tyre to Winter
Your running app still has type_tyre equals Sommer
You attempt to change tyres while driving on the highway
Crash
And this while changing the tyres before starting the car might be a trivial and safe thing to do.
So you just have to write a routine that adjusts the state of your application according to the change in preferences but this is in general different from initializing the app and depends on the current state of the app. But otherwise just write such a routine and call it. | 1 | 699 | 0 | 0 | 2014-07-16T15:45:00.000 | python,pyqt,updating,configparser | Python - update configparser between modules | 0 | 1 | 2 | 24,871,124 | 1 |
0 | 0 | I have an application made up of Frames, Frames in Frames and Labels in Frames. There is quite a lot of them and I am looking for a way to modify some of the default values.
I am particularly interested in modifying .columnconfigure() since I call .columnconfigure(0, weight=1) on each of the columns, in each frame. This does not help with the code cleanness.
Is there a way to set this behavior (ability to expand) globally? | true | 24,806,713 | 1.2 | 0 | 0 | 3 | No, there is no way to change the defaults. You can easily write your own grid function to automatically configure the weight of each column. You could do this by subclassing Frame, for instance. | 0 | 207 | 0 | 0 | 2014-07-17T14:46:00.000 | python,tkinter | how to change default values for .columnconfigure() in tkinter? | 0 | 1 | 2 | 24,814,914 | 1 |
0 | 0 | I have two questions that I can not answer to myself:
How can I change the size of my window, if I do not know the exact size of the phone screen? I.e. my aim is to fit all screen sizes.
Is there any difference between clicking with mouse and touching with fingers in the code? If I write code for clicking, will it work with touch? | true | 24,830,313 | 1.2 | 0 | 0 | 2 | On mobile, your app should automatically fill the phone screen. You don't need to worry about it. On desktop, you can use the --size=WxH option to test a specific screen size, or use the screen module (-m screen:nexus7 for example - run kivy with -m screen to see the available options).
No. All mouse/touchscreen interactions are considered touches in Kivy. So using on_touch_down/on_touch_move/on_touch_up will work regardless of the input device. The only difference is that with touchscreen you could have multi-touch - but if you write your app assuming single-touch it will work the same on both mobile and desktop. | 0 | 399 | 0 | 1 | 2014-07-18T17:02:00.000 | android,python,kivy | Kivy: how to change window size properties and the difference between click and touch | 0 | 1 | 1 | 24,830,380 | 1 |
0 | 0 | Good afternoon,
I'm using a QTableview+QAbstractTableModel to display a potentially large amount of data (20k+ rows) were each row consists of cells holding text of various length, including newlines, displayed using a custom delegate. The data resides in memory (no database, stream or similar) and might be changed from outside the table. To adapt the row height to changes of the text, I set the Resize Mode of the TableView's vertical header to "ResizeToContents" which correctly uses the sizeHint of my delegate to set the height.
This works well and all, however depending on the size of the table the performance is abysmal (several minutes to load a large table). Once I turn off the resize mode, loading is as fast as lightning but of course the row height is incorrect (causing text with newlines to overlap rows, etc.). It seems that when using the auto-resize mode, every cell in every row is queried for the size hint, which takes a lot of time (confirmed by printing a debug msg in the sizeHint function of my delegate).
I wonder if this is the intended behaviour of the ResizeToContents mode, as I would assume that it would only be necessary to query the actually visible rows of the TableView - not all rows (as given by the rowCounts() call). As only a fraction of the rows are displayed at any one time, this would of course improve the performance noticeably. Is this a bug/shortcoming in the resize code or do I misunderstand something about this functionality? By the way, I'm using PyQt 4.10 so maybe this behaviour changed in newer versions?
Thanks in advance for all hints. | false | 24,864,255 | 0.197375 | 0 | 0 | 1 | If you set verticalHeader.sizeHint to ResizeToContents, on any row update ALL table will be processed to obtain new column width. This behaviour is life saver for most of us, if we don't have a large table that frequently update.
First, don't use resizeToContents size hint!
Basic solution: use fixed size for columns with stretch option. (i think, it is not for you)
Solution, i use: i have timer to call resizeColumnsToContents() slot at intervals of 2 seconds.
Solution, optimized: You can optimize my solution to your case. Such as, you can wait until all row data updated to call resize slot.
Answer for your suggestion(resize for just visible items): it is not useful. | 0 | 772 | 0 | 2 | 2014-07-21T11:42:00.000 | python,qt,pyqt4 | QTableview - ResizeToContents queries every row? | 0 | 1 | 1 | 24,951,937 | 1 |
0 | 0 | I am pretty new to python, my background is with VB visual studios, I am trying to develop a app in which I want to consume WCF service. Found Suds is the required python module.
I am using Kivy 1.8.0 and Eclipse with pydev on Windows 7 64bit. Could you please point me in correct direction on how to instal the package, found no exe, I have run the setup.py from suds but did not work.
Any advice/direction towards tutorial is of great help. | true | 24,954,106 | 1.2 | 0 | 0 | 0 | Are you by any chance running the Python 3 version of Kivy? Suds looks like it is abandondonware (last release in 2010) and likely does not have a Python3 port. You may have luck with the Python2.7 version of Kivy and pip installing suds, but keep in mind you will be relying on an apparently unsupported module (suds) for your project. | 1 | 396 | 0 | 1 | 2014-07-25T10:53:00.000 | python,installation,kivy,suds | Kivy with suds - module installation | 0 | 1 | 2 | 25,000,617 | 1 |
0 | 0 | How can I get raw base64 PNG data from a PyQt4.QtGui.QImage object? The only method I can find that seems like it would help is bits(), but that just returns a sip.voidptr object and I have no idea where to go from there. | false | 24,965,646 | -0.197375 | 0 | 0 | -2 | You have the right method if you want to directly access the data in memory. It is a C array, and has no python object associated, so it's a little tricky. You need: the start address from bits(), the depth() and the byteCount(). ctypes.string_at would give you access to the data there, which you would pass to a numpy array using the known bits-per-pix and image shape.
I won't write more, because this kind of thing is likely to cause a crash (and I have no test data right now) - can you not load the image in the usual way? | 0 | 1,434 | 0 | 0 | 2014-07-25T22:52:00.000 | python,qt,python-3.x,pyqt | Convert PyQt4.QtGui.QImage object to base64 PNG data | 0 | 1 | 2 | 24,965,943 | 1 |
Subsets and Splits