Rework more windows to use aux frame

This commit is contained in:
DarkPhoenix
2019-08-12 00:32:27 +03:00
parent fc65cb6000
commit 34a6fdc07e
10 changed files with 68 additions and 256 deletions

View File

@@ -24,19 +24,19 @@ import wx
class AuxiliaryFrame(wx.Frame):
def __init__(self, parent, id=None, title=None, pos=None, size=None, style=None, name=None):
baseStyle = wx.FRAME_NO_TASKBAR | wx.FRAME_FLOAT_ON_PARENT | wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU
kwargs = {
'parent': parent,
'style': baseStyle if style is None else baseStyle | style}
if id is not None:
kwargs['id'] = id
if title is not None:
kwargs['title'] = title
if pos is not None:
kwargs['pos'] = pos
if size is not None:
kwargs['size'] = size
if name is not None:
kwargs['name'] = name
super().__init__(**kwargs)
def __init__(self, parent, id=None, title=None, pos=None, size=None, style=None, name=None):
baseStyle = wx.FRAME_NO_TASKBAR | wx.FRAME_FLOAT_ON_PARENT | wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU
kwargs = {
'parent': parent,
'style': baseStyle if style is None else baseStyle | style}
if id is not None:
kwargs['id'] = id
if title is not None:
kwargs['title'] = title
if pos is not None:
kwargs['pos'] = pos
if size is not None:
kwargs['size'] = size
if name is not None:
kwargs['name'] = name
super().__init__(**kwargs)

View File

@@ -141,31 +141,3 @@ class AttributeSlider(wx.Panel):
# Stop animations to prevent crashes when window is
# closed while animation is in progress
self.slider.FreezeAnimation()
class TestAttributeSlider(wx.Frame):
def __init__(self, parent, id):
title = 'Slider...'
pos = wx.DefaultPosition
size = wx.DefaultSize
sty = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, parent, id, title, pos, size, sty)
self.panel = AttributeSlider(self, -50, 0.8, 1.5, False)
self.panel.Bind(EVT_VALUE_CHANGED, self.thing)
self.panel.SetValue(-55)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def OnCloseWindow(self, event):
self.Destroy()
def thing(self, evt):
print("thing")
if __name__ == "__main__":
app = wx.App()
frame = TestAttributeSlider(None, wx.ID_ANY)
frame.Show()
app.MainLoop()

View File

@@ -346,45 +346,3 @@ class ItemParams(wx.Panel):
else:
fvalue = value
return "%s %s" % (fvalue, unit)
if __name__ == "__main__":
import eos.db
# need to set up some paths, since bitmap loader requires config to have things
# Should probably change that so that it's not dependant on config
import os
os.chdir('..')
import config
config.defPaths(None)
config.debug = True
class Frame(wx.Frame):
def __init__(self, ):
# item = eos.db.getItem(23773) # Ragnarok
item = eos.db.getItem(23061) # Einherji I
#item = eos.db.getItem(24483) # Nidhoggur
#item = eos.db.getItem(587) # Rifter
#item = eos.db.getItem(2486) # Warrior I
#item = eos.db.getItem(526) # Stasis Webifier I
item = eos.db.getItem(486) # 200mm AutoCannon I
#item = eos.db.getItem(200) # Phased Plasma L
super().__init__(None, title="Test Attribute Window | {} - {}".format(item.ID, item.name), size=(1000, 500))
if 'wxMSW' in wx.PlatformInfo:
color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
self.SetBackgroundColour(color)
main_sizer = wx.BoxSizer(wx.HORIZONTAL)
panel = ItemParams(self, None, item)
main_sizer.Add(panel, 1, wx.EXPAND | wx.ALL, 2)
self.SetSizer(main_sizer)
self.Layout()
app = wx.App(redirect=False) # Error messages go to popup window
top = Frame()
top.Show()
app.MainLoop()

View File

@@ -3,8 +3,9 @@ import wx
class PFBitmapFrame(wx.Frame):
def __init__(self, parent, pos, bitmap):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=pos, size=wx.DefaultSize,
style=wx.NO_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP)
super().__init__(
parent, id=wx.ID_ANY, title=wx.EmptyString, pos=pos, size=wx.DefaultSize,
style=wx.NO_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP)
img = bitmap.ConvertToImage()
img = img.ConvertToGreyscale()
bitmap = wx.Bitmap(img)
@@ -32,14 +33,14 @@ class PFBitmapFrame(wx.Frame):
if self.transp < 0:
self.transp = 0
self.timer.Stop()
wx.Frame.Show(self, False)
super().Show(False)
self.Destroy()
return
self.SetTransparent(self.transp)
def Show(self, showWnd=True):
if showWnd:
wx.Frame.Show(self, showWnd)
super().Show(showWnd)
self.Parent.SetFocus()
self.direction = 1
self.timer.Start(5)

View File

@@ -17,16 +17,18 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================
# import platform
import datetime
import sys
#
import traceback
# noinspection PyPackageRequirements
import wx
import traceback
import config
from logbook import Logger
import config
from gui.auxFrame import AuxiliaryFrame
from service.prereqsCheck import version_block
import datetime
pyfalog = Logger(__name__)
@@ -59,11 +61,12 @@ class ErrorHandler:
cls.__parent = parent
class ErrorFrame(wx.Frame):
class ErrorFrame(AuxiliaryFrame):
def __init__(self, parent=None, error_title='Error!'):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="pyfa error", pos=wx.DefaultPosition, size=wx.Size(500, 600),
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER | wx.STAY_ON_TOP)
super().__init__(
parent, id=wx.ID_ANY, title="pyfa error", pos=wx.DefaultPosition,
size=wx.Size(500, 600), style=wx.STAY_ON_TOP)
from eos.config import gamedata_version, gamedata_date

View File

@@ -1,30 +1,31 @@
import json
import requests
# noinspection PyPackageRequirements
import wx
import requests
from service.port import Port
from service.fit import Fit
from eos.saveddata.cargo import Cargo
from eos.db import getItem
from gui.display import Display
import gui.globalEvents as GE
from logbook import Logger
import gui.globalEvents as GE
from eos.db import getItem
from eos.saveddata.cargo import Cargo
from gui.auxFrame import AuxiliaryFrame
from gui.display import Display
from service.esi import Esi
from service.esiAccess import APIException
from service.fit import Fit
from service.port import Port
from service.port.esi import ESIExportException
pyfalog = Logger(__name__)
class EveFittings(wx.Frame):
class EveFittings(AuxiliaryFrame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Browse EVE Fittings", pos=wx.DefaultPosition,
size=wx.Size(750, 450), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT)
super().__init__(
parent, id=wx.ID_ANY, title="Browse EVE Fittings", pos=wx.DefaultPosition,
size=wx.Size(750, 450), style=wx.RESIZE_BORDER)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
@@ -194,11 +195,12 @@ class ESIExceptionHandler:
raise ex
class ExportToEve(wx.Frame):
class ExportToEve(AuxiliaryFrame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition,
size=(wx.Size(350, 100)), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
super().__init__(
parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition,
size=(wx.Size(350, 100)), style=wx.RESIZE_BORDER)
self.mainFrame = parent
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
@@ -228,7 +230,7 @@ class ExportToEve(wx.Frame):
self.SetStatusBar(self.statusbar)
self.Layout()
self.Centre(wx.BOTH)
self.Center(wx.BOTH)
def updateCharList(self):
sEsi = Esi.getInstance()

View File

@@ -2,34 +2,29 @@ import csv
# noinspection PyPackageRequirements
import wx
# noinspection PyPackageRequirements
import wx.propgrid as wxpg
from logbook import Logger
try:
# noinspection PyPackageRequirements
import wx.propgrid as wxpg
except:
if wx.VERSION < (2, 9):
raise ImportError("wx.propgrid is only available in wxPython >= 2.9")
else:
raise
from eos.db.gamedata.queries import getItem, getAttributeInfo
from service.market import Market
import gui.builtinMarketBrowser.pfSearchBox as SBox
import gui.display as d
import gui.globalEvents as GE
import gui.builtinMarketBrowser.pfSearchBox as SBox
from gui.marketBrowser import SearchBox
from eos.db.gamedata.queries import getAttributeInfo, getItem
from gui.auxFrame import AuxiliaryFrame
from gui.bitmap_loader import BitmapLoader
from gui.marketBrowser import SearchBox
from service.market import Market
pyfalog = Logger(__name__)
class AttributeEditor(wx.Frame):
class AttributeEditor(AuxiliaryFrame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, wx.ID_ANY, title="Attribute Editor", pos=wx.DefaultPosition,
size=wx.Size(650, 600),
style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT | wx.TAB_TRAVERSAL)
super().__init__(
parent, wx.ID_ANY, title="Attribute Editor", pos=wx.DefaultPosition,
size=wx.Size(650, 600), style=wx.RESIZE_BORDER)
i = wx.Icon(BitmapLoader.getBitmap("fit_rename_small", "gui"))
self.SetIcon(i)

View File

@@ -392,64 +392,3 @@ class PyGauge(wx.Window):
self._timer.Stop()
self.Refresh()
if __name__ == "__main__":
def frange(x, y, jump):
while x < y:
yield x
x += jump
class MyPanel(wx.Panel):
def __init__(self, parent, size=(500, 500)):
wx.Panel.__init__(self, parent, size=size)
box = wx.BoxSizer(wx.VERTICAL)
# tests the colors of transition based on percentage used
# list of test values (from 99 -> 106 in increments of 0.5)
tests = [x for x in frange(99, 106.5, .5)]
font = wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
for i, value in enumerate(tests):
self.gauge = PyGauge(self, font, size=(100, 25))
self.gauge.SetValueRange(value, 100)
self.gauge.SetFractionDigits(2)
box.Add(self.gauge, 0, wx.ALL, 2)
gauge = PyGauge(self, font, size=(100, 25))
gauge.SetBackgroundColour(wx.Colour(52, 86, 98))
gauge.SetBarColour(wx.Colour(38, 133, 198))
gauge.SetValue(59)
gauge.SetFractionDigits(1)
box.Add(gauge, 0, wx.ALL, 2)
gauge = PyGauge(self, font, size=(100, 5))
gauge.SetBackgroundColour(wx.Colour(52, 86, 98))
gauge.SetBarColour(wx.Colour(255, 128, 0))
gauge.SetValue(59)
gauge.SetFractionDigits(1)
box.Add(gauge, 0, wx.ALL, 2)
self.SetSizer(box)
self.Layout()
# see animation going backwards with last gauge
wx.CallLater(2000, self.ChangeValues)
def ChangeValues(self):
self.gauge.SetValueRange(4, 100)
class Frame(wx.Frame):
def __init__(self, title, size=(500, 800)):
wx.Frame.__init__(self, None, title=title, size=size)
self.statusbar = self.CreateStatusBar()
main_sizer = wx.BoxSizer(wx.VERTICAL)
panel = MyPanel(self, size=size)
main_sizer.Add(panel)
self.SetSizer(main_sizer)
app = wx.App(redirect=False) # Error messages go to popup window
top = Frame("Test Chrome Tabs")
top.Show()
app.MainLoop()

View File

@@ -27,6 +27,7 @@ from logbook import Logger
import gui.mainFrame
import gui.globalEvents as GE
from gui.auxFrame import AuxiliaryFrame
from gui.bitmap_loader import BitmapLoader
from gui.builtinViews.entityEditor import EntityEditor, BaseValidator
from gui.utils.clipboard import toClipboard, fromClipboard
@@ -111,7 +112,7 @@ class TargetProfileEntityEditor(EntityEditor):
wx.PostEvent(self.mainFrame, GE.TargetProfileRemoved(profileID=entity.ID))
class TargetProfileEditor(wx.Frame):
class TargetProfileEditor(AuxiliaryFrame):
DAMAGE_TYPES = OrderedDict([
("em", "EM resistance"),
@@ -124,9 +125,8 @@ class TargetProfileEditor(wx.Frame):
('radius', ('Radius', 'm'))])
def __init__(self, parent, selected=None):
wx.Frame.__init__(
self, parent, id=wx.ID_ANY,
title="Target Profile Editor", style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT,
super().__init__(
parent, id=wx.ID_ANY, title="Target Profile Editor", style=wx.RESIZE_BORDER,
# Dropdown list widget is scaled to its longest content line on GTK, adapt to that
size=wx.Size(500, 240) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 240))

View File

@@ -141,61 +141,3 @@ class TogglePanel(wx.Panel):
self.parent.Layout()
else:
self.OnStateChange(self.GetBestSize())
if __name__ == "__main__":
from wx.lib.inspection import InspectionTool
class MainPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent, size=(-1, -1))
if 'wxMSW' in wx.PlatformInfo:
color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
self.SetBackgroundColour(color)
main_sizer = wx.BoxSizer(wx.VERTICAL)
# Generate 3 test panels with different font sizes
for x in range(3):
toggle_panel = TogglePanel(self)
toggle_panel.SetLabel("Test Header")
content_panel = toggle_panel.GetContentPanel()
content_panel.SetBackgroundColour(wx.WHITE)
content_sizer = wx.BoxSizer(wx.HORIZONTAL)
header = wx.StaticText(content_panel, -1, "TogglePanel Test")
header.SetFont(wx.Font(10 + (x * 3), wx.SWISS, wx.NORMAL, wx.BOLD))
content_sizer.Add(header, 0, wx.ALL, 10)
content_panel.SetSizer(content_sizer)
main_sizer.Add(toggle_panel, 0, wx.EXPAND | wx.ALL, 2)
self.SetSizer(main_sizer)
class Frame(wx.Frame):
def __init__(self, title):
super().__init__(None, title=title, size=(500, 500))
main_sizer = wx.BoxSizer(wx.VERTICAL)
self.statsPane = MainPanel(self)
main_sizer.Add(self.statsPane, 0, wx.EXPAND)
self.SetSizerAndFit(main_sizer)
if not InspectionTool().initialized:
InspectionTool().Init()
# Find a widget to be selected in the tree. Use either the
# one under the cursor, if any, or this frame.
wnd, _ = wx.FindWindowAtPointer()
if not wnd:
wnd = self
InspectionTool().Show(wnd, True)
app = wx.App(redirect=False) # Error messages go to popup window
top = Frame("Test Toggle Panel")
top.Show()
app.MainLoop()