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

Implement canvas.set_title() #508

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions wgpu/gui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def set_logical_size(self, width, height):
"""Set the window size (in logical pixels)."""
raise NotImplementedError()

def set_title(self, title):
"""Set the window title."""
raise NotImplementedError()

def close(self):
"""Close the window."""
pass
Expand Down
3 changes: 3 additions & 0 deletions wgpu/gui/glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ def set_logical_size(self, width, height):
raise ValueError("Window width and height must not be negative")
self._set_logical_size((float(width), float(height)))

def set_title(self, title):
glfw.set_window_title(self._window, title)

def _request_draw(self):
if not self._request_draw_timer_running:
self._request_draw_timer_running = True
Expand Down
3 changes: 3 additions & 0 deletions wgpu/gui/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def set_logical_size(self, width, height):
self.css_width = f"{width}px"
self.css_height = f"{height}px"

def set_title(self, title):
pass # not supported yet

def close(self):
RemoteFrameBuffer.close(self)

Expand Down
3 changes: 3 additions & 0 deletions wgpu/gui/offscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def get_physical_size(self):
def set_logical_size(self, width, height):
self._logical_size = width, height

def set_title(self, title):
pass

def close(self):
self._closed = True

Expand Down
6 changes: 6 additions & 0 deletions wgpu/gui/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def set_logical_size(self, width, height):
raise ValueError("Window width and height must not be negative")
self.resize(width, height) # See comment on pixel ratio

def set_title(self, title):
self.setWindowTitle(title)

def _request_draw(self):
if not self._request_draw_timer.isActive():
self._request_draw_timer.start(int(self._get_draw_wait_time() * 1000))
Expand Down Expand Up @@ -405,6 +408,9 @@ def set_logical_size(self, width, height):
raise ValueError("Window width and height must not be negative")
self.resize(width, height) # See comment on pixel ratio

def set_title(self, title):
self.setWindowTitle(title)

def _request_draw(self):
return self._subwidget._request_draw()

Expand Down
6 changes: 6 additions & 0 deletions wgpu/gui/wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def set_logical_size(self, width, height):
raise ValueError("Window width and height must not be negative")
self.SetSize(width, height)

def set_title(self, title):
pass # only on frames

def _request_draw(self):
# Despite the FPS limiting the delayed call to refresh solves
# that drawing only happens when the mouse is down, see #209.
Expand Down Expand Up @@ -172,6 +175,9 @@ def set_logical_size(self, width, height):
raise ValueError("Window width and height must not be negative")
self.SetSize(width, height)

def set_title(self, title):
self.SetTitle(title)

def _request_draw(self):
return self._subwidget._request_draw()

Expand Down
Loading