MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / PFNotebookPagePreview

Class PFNotebookPagePreview

gui/chrome_tabs.py:1428–1526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1426
1427
1428class PFNotebookPagePreview(wx.Frame):
1429 def __init__(self, parent, pos, bitmap, title):
1430 super().__init__(parent, id=wx.ID_ANY, title=wx.EmptyString, pos=pos,
1431 size=wx.DefaultSize, style=wx.NO_BORDER |
1432 wx.FRAME_NO_TASKBAR |
1433 wx.STAY_ON_TOP)
1434 self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
1435 self.title = title
1436 self.bitmap = bitmap
1437 self.SetSize((bitmap.GetWidth(), bitmap.GetHeight()))
1438 self.Bind(wx.EVT_PAINT, self.OnWindowPaint)
1439 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnWindowEraseBk)
1440 self.Bind(wx.EVT_TIMER, self.OnTimer)
1441
1442 self.timer = wx.Timer(self, wx.ID_ANY)
1443 self.timerSleep = None
1444 self.timerSleepId = wx.NewId()
1445 self.direction = 1
1446 self.padding = 15
1447 self.transp = 0
1448
1449 hfont = wx.Font(fonts.NORMAL, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
1450 self.SetFont(hfont)
1451
1452 tx, ty = self.GetTextExtent(self.title)
1453 tx += self.padding * 2
1454
1455 if bitmap.GetWidth() < tx:
1456 width = tx
1457 else:
1458 width = bitmap.GetWidth()
1459
1460 self.SetSize((width, bitmap.GetHeight() + 16))
1461
1462 self.SetTransparent(0)
1463 self.Refresh()
1464
1465 def OnTimer(self, event):
1466 self.transp += 20 * self.direction
1467
1468 if self.transp > 220:
1469 self.transp = 220
1470 self.timer.Stop()
1471
1472 if self.transp < 0:
1473 self.transp = 0
1474 self.timer.Stop()
1475 super().Show(False)
1476 self.Destroy()
1477 return
1478 self.SetTransparent(self.transp)
1479
1480 def RaiseParent(self):
1481 wnd = self
1482 lastwnd = None
1483 while wnd is not None:
1484 lastwnd = wnd
1485 wnd = wnd.Parent

Callers 1

OnTimerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected