fixing launching mangle from a different working directory

This commit is contained in:
Alex Yatskov 2011-10-31 19:41:24 -07:00
parent e2903bee8f
commit a5f4a54b41
4 changed files with 29 additions and 3 deletions

View File

@ -15,10 +15,11 @@
import os.path import os.path
import util
from PyQt4 import QtGui, uic from PyQt4 import QtGui, uic
class DialogAbout(QtGui.QDialog): class DialogAbout(QtGui.QDialog):
def __init__(self, parent): def __init__(self, parent):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
uic.loadUi('mangle/resource/ui/about.ui', self) uic.loadUi(util.buildResPath('mangle/resource/ui/about.ui'), self)

View File

@ -16,6 +16,7 @@
import os import os
import os.path import os.path
import util
from PyQt4 import QtGui, QtCore, QtXml, uic from PyQt4 import QtGui, QtCore, QtXml, uic
from image import ImageFlags from image import ImageFlags
from about import DialogAbout from about import DialogAbout
@ -111,7 +112,7 @@ class MainWindowBook(QtGui.QMainWindow):
def __init__(self, filename=None): def __init__(self, filename=None):
QtGui.QMainWindow.__init__(self) QtGui.QMainWindow.__init__(self)
uic.loadUi('mangle/resource/ui/book.ui', self) uic.loadUi(util.buildResPath('mangle/resource/ui/book.ui'), self)
self.listWidgetFiles.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.listWidgetFiles.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.actionFileNew.triggered.connect(self.onFileNew) self.actionFileNew.triggered.connect(self.onFileNew)
self.actionFileOpen.triggered.connect(self.onFileOpen) self.actionFileOpen.triggered.connect(self.onFileOpen)

View File

@ -15,6 +15,7 @@
import os.path import os.path
import util
from PyQt4 import QtGui, QtCore, uic from PyQt4 import QtGui, QtCore, uic
from image import ImageFlags from image import ImageFlags
@ -23,7 +24,7 @@ class DialogOptions(QtGui.QDialog):
def __init__(self, parent, book): def __init__(self, parent, book):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
uic.loadUi('mangle/resource/ui/options.ui', self) uic.loadUi(util.buildResPath('mangle/resource/ui/options.ui'), self)
self.accepted.connect(self.onAccept) self.accepted.connect(self.onAccept)
self.book = book self.book = book

23
mangle/util.py Normal file
View File

@ -0,0 +1,23 @@
# Copyright (C) 2010 Alex Yatskov
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import os.path
def buildResPath(relative):
directory = os.path.split(sys.argv[0])[0]
return os.path.join(directory, relative)