Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 19th, 2008, 03:57 AM
krank23 krank23 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 krank23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 12 sec
Reputation Power: 0
Py2exe and WxPython XRC issues

Hello. First poster here, so please be gentle.

I'm writing a WxPython-based program using XRC resource files for the UI design. The prog works magnificently when run as regular pyw.

However, I want to compile it, and py2exe seemed like the most reasonable choice (pyinstaller unpacks stuff to temporary locations, and I'm kind of allergic to that kind of behavior).

Problem is, py2exe seems to think it shouldn't include the XRC file in the resource.zip, but then the exe tries to find the damn thing there anyways.

OK, some code for you to try:

fiff.py
Code:
import os
import wx
from wx import xrc
import sys

# Graphical stuff

class TempestApp(wx.App):
    def OnInit(self): ## When the application class is instanced...
        self.res = ""
        self.res = wx.xrc.XmlResource(sys.path[0] + "\\noname.xrc") ## load the xrc file into self.res
        self.init_frame() ## Initialize main frame and its bindings
        return True
    
    ## Initializing
    def init_frame(self):
        self.frame = self.res.LoadFrame(None, 'FrameMain')
        self.frame = wx.Frame(None, -1, "Hello World")

Tempest = TempestApp()
Tempest.frame.Show()
Tempest.MainLoop()


setup.py
Code:
# setup.py
import sys, os
from distutils.core import setup
import py2exe
import glob

setup(console=["fiff.py"])


...and the noname.xrc:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
	<object class="wxFrame" name="FrameMain">
		<style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
		<size>480,400</size>
		<title>Tempest</title>
		<object class="wxPanel" name="m_panel11">
			<style>wxTAB_TRAVERSAL</style>
			<object class="wxBoxSizer">
				<orient>wxHORIZONTAL</orient>
				<object class="sizeritem">
					<option>0</option>
					<flag>wxALL</flag>
					<border>5</border>
					<object class="wxStaticText" name="m_staticText1">
						<label>Project:</label>
					</object>
				</object>
				<object class="sizeritem">
					<option>1</option>
					<flag>wxALL</flag>
					<border>5</border>
					<object class="wxTextCtrl" name="TxtProjectName">
						<value></value>
						<maxlength>0</maxlength>
					</object>
				</object>
			</object>
		</object>
	</object>
</resource>




What I want:
I want the generated fiff.exe to see noname.xrc as an external resource. The point here is to be able to edit the interface without recompiling the exe.

What I've tried:
* I've tried adding data_files=[ ("",["noname.xrc",])] to the setup.py. That just copied the noname.xrc to the dist dir.
* To even get the error message, I had to add the <i>self.frame = wx.Frame(None, -1, "Hello World")</i> row. If commented, the fiff.exe doesn't even give me an error, it just flashes an error window and closes down.
* I've tried adding noname.xrc to the library.zip, but that didn't change anything.

There. I don't think I've forgotten anything. Please, any comment or help is deeply appreciated.

Reply With Quote
  #2  
Old April 19th, 2008, 11:59 AM
c-2501 c-2501 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Location: Scotland
Posts: 28 c-2501 User rank is Corporal (100 - 500 Reputation Level)c-2501 User rank is Corporal (100 - 500 Reputation Level)c-2501 User rank is Corporal (100 - 500 Reputation Level)c-2501 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 22 m 21 sec
Reputation Power: 0
Here's what (I think) you need to do.

First change
Code:
self.res = wx.xrc.XmlResource(sys.path[0] + "\\noname.xrc")

to simply read
Code:
self.res = wx.xrc.XmlResource("noname.xrc")
then just copy the noname.xrc (or add the data_files=... part back into your setup.py and this should solve the probelm.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Py2exe and WxPython XRC issues


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway