Last active
May 3, 2023 17:45
-
-
Save komoto48g/ba11322fcd325f46102deba589c23b08 to your computer and use it in GitHub Desktop.
Sleep tight tonight.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Sleep tight | |
:caution: Don't gaze too long. | |
""" | |
import numpy as np | |
import wx | |
import wx.lib.throbber as throb | |
N = 256 | |
def ctf(phase): | |
r = 20 * np.arange(-N/2, N/2) / N | |
X, Y = np.meshgrid(r, r) | |
f = np.sin(X**2 + Y**2 - phase * 2 * np.pi) | |
src = (255 * f ** 2).astype(np.uint8) | |
buf = src.repeat(3,1).tobytes() | |
return wx.Image(N, N, buf) | |
class TestPanel(wx.Panel): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
images = [ctf(x).ConvertToBitmap() for x in np.arange(10)/10] | |
self.throb = throb.Throbber(self, -1, images, frameDelay=0.1, | |
label="You're sleepy.\n" | |
"You're sleeping.\n" | |
"You sleep tight...\n") | |
self.throb.Font = wx.Font(14, | |
wx.FONTFAMILY_DEFAULT, | |
wx.FONTSTYLE_NORMAL, | |
wx.FONTWEIGHT_EXTRABOLD) | |
self.throb.Start() | |
## self.throb.Rest() | |
if __name__ == "__main__": | |
app = wx.App() | |
frm = wx.Frame(None) | |
frm.panel = TestPanel(frm) | |
frm.Show() | |
app.MainLoop() |
Author
komoto48g
commented
May 3, 2023
Buy me a coffee...
Buy me a coffee...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment