Comments (9)
Hi,
how are you trying to create your window?
If you created using StandAloneContainer, you are able to use the setWindowIcon over it.
If that doesn't work for you, can you post here what you tried please?
Thanks
from pyforms-gui.
The main window is BaseWidget class, and I think created the main window with start_app. I was looking at the start_app code and it doesn't directly expose the SandAloneContainer. How should I be creating the main window?
from pyforms-gui.
Have you tried accessing the main window through the object that you passed to the start_app?
There, you have a property called app_main_window, which you can call the setWindowIcon over.
If you aren't able to do that, and if you can, post the code you tried please.
from pyforms-gui.
not really sure how to do that, it looks like app_main_window is a property of StandAloneContainer which is created inside start_app but not directly exposed. Am I missing something? The app I am trying to create is a simple app with just a couple of buttons. I'm not sure how to access the passed object. If is initiate it with mydrives=MyDrives(), mydrives.a_main_window.setWindowIcon(icon) gives an error.
Thanks for any and all help
mydrives.py
import pyforms
from pyforms.basewidget import BaseWidget
from pyforms.controls import (
ControlButton,
ControlText
)
import yaml
import subprocess
import os
from AnyQt.QtGui import QIcon
class MyDrives(BaseWidget):
def __init__(self, *args, **kwargs):
super().__init__('MyDrives')
USER = os.environ['USER']
drives = {}
drives['home'] = {
'smb': f'smb://<drive>/user/{USER}',
'mountpoint': f'{USER}',
'name': 'Home'
}
self._formset = []
for drive in drives:
self.__dict__[drive] = ControlButton('Mount ' + drives[drive]['name'])
self.__dict__['u'+drive] = ControlButton('Unmount ' + drives[drive]['name'])
self.__dict__['mount'+drive] = self.mountCallback(drives[drive])
self.__dict__[drive].value = self.__dict__['mount'+drive]
self.__dict__['unmount'+drive] = self.unmountCallback(drives[drive])
self.__dict__['u'+drive].value = self.__dict__['unmount'+drive]
self._formset.append((drive, 'u'+drive))
def mountCallback(self, drive):
def callback():
try:
subprocess.call(['osascript', '-e', 'mount volume "{}"'.format(drive['smb'])])
subprocess.call(['open', '/Volumes/{}'.format(drive['mountpoint'])])
except:
pass
return callback
def unmountCallback(self, drive):
def callback():
try:
subprocess.call(['diskutil', 'unmount', '/Volumes/{}'.format(drive['mountpoint'])])
except:
pass
return callback
if __name__ == '__main__':
icon = os.path.join(os.path.dirname(__name__), 'MapDrives.png')
from pyforms import start_app
start_app(MyDrives)
from pyforms-gui.
Hi,
I added the possibility to set the main window icon through a user settings file. Currently is still in the develop branch but will soon (hopefully during next week) be released with a new update on pip for pyforms-gui.
The way that afterwards you should use it is to have a file where you would put your application settings (e.g., settings.py) in your module's folder.
There you will be able to set an entry with
SETTINGS_PRIORITY = 0
PYFORMS_MAIN_WINDOW_ICON_PATH = 'path_to_your_icon_file_either_svg_or_png'
With that, your code would change to:
if __name__ == '__main__':
import settings as user_settings
from pyforms import start_app
start_app(MyDrives, user_settings=user_settings)
start_app will handle that setting if it is defined and you should be seeing your icon as expected.
Thanks for pointing this out. I will close this issue when the new release is out.
Edited: The code to get the icon path setting so the use will be simpler.
from pyforms-gui.
Excellent thank you!
from pyforms-gui.
In a similar way could you allow the use of showNormal or showMinimzed rather then showMaximized
with a setting?
from pyforms-gui.
You can update to the new minor version with pip right now.
from pyforms-gui.
Thank you this works great
from pyforms-gui.
Related Issues (20)
- ControlFilesTree - how to get selected file?
- how to control size of main window HOT 1
- How to style window
- Use QListWidgetItem instead of QTableWidgetItem for ControlList
- populating ControlList takes veeeryyyy loooong time HOT 1
- Window starts maximized
- Can't seem to get the mainmenu to show for MacOS
- OpenCV version issue
- ControlNumber can't set negative value
- opencv-python==3.4.5.0 could not be installed
- Not getting the complete file path when using the ControlFile widget to save a file HOT 1
- function 'FT_New_Face' not found
- How to package into exe file
- GUI docs Controls descriptions not available
- Pyforms Tutorial Missing "AddMenuFuntionality" HOT 1
- qt.qpa.xcb: could not connect to display
- Is there an updated doc on how to import CSS Styles? HOT 2
- In a similar way could you allow the use of showNormal or showMinimzed rather then showMaximized HOT 1
- ImportError: PyQt4, PyQt5, PySide or PySide2 are not available for import HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyforms-gui.