Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Fixed path separators for usdview stylesheet #113

Merged
merged 2 commits into from
Jan 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pxr/usdImaging/lib/usdviewq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,19 @@ def __LaunchProcess(self, arg_parse_result):
from mainWindow import MainWindow
if arg_parse_result.clearSettings:
MainWindow.clearSettings()
# find the resource directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @krzykli, sorry for the delay on this. I noticed that at line 162 we call os.path.join, which will reintroduce a '' character to the path given to open(...) on Windows. This seems to work but feels a little odd. I think it'd be better if we leave line 155 the way it was, move the resourceDir.replace call to line 163, and add a comment stating we need to replace the slashes because the Qt stylesheet needs all slashes to be '/'. How does that sound?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sunyab, sounds good to me. I've addressed it on my branch.

# Find the resource directory
resourceDir = os.path.dirname(os.path.realpath(__file__)) + "/"

# Create the Qt application
app = QApplication(sys.argv)

# apply the style sheet to it
# Apply the style sheet to it
sheet = open(os.path.join(resourceDir, 'usdviewstyle.qss'), 'r')
sheetString = sheet.read().replace('RESOURCE_DIR', resourceDir)

# Qt style sheet accepts only forward slashes as path separators
sheetString = sheet.read().replace('RESOURCE_DIR',
resourceDir.replace("\\", "/"))
app.setStyleSheet(sheetString)

mainWindow = MainWindow(None, arg_parse_result)
Expand Down