Hello for everyone!
My English is bad, I'm new here, but I hope you understand me.
I am a student. To solve my problem, I decided to create a workbench.
I have 3 questions:
1. What should be a structure of module?
I have a few finished pieces of code with the GUI (PyQt). I looked through the code in arch module, but do not quite understand how my pieces have to be arranged.
2. Achievements I need to store in the database. Database file should be placed in the folder of the module? Could this become a problem?
3. How to add commands to the context menu?
I would be grateful for an answer or links to the information I needed.
project structure and database
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: project structure and database
Check here:
http://freecadweb.org/wiki/index.php?ti ... e_Creation
And:
https://github.com/FreeCAD/FreeCAD_sf_m ... platePyMod
Those helped me a lot in understanding how the workbench modules function.
http://freecadweb.org/wiki/index.php?ti ... e_Creation
And:
https://github.com/FreeCAD/FreeCAD_sf_m ... platePyMod
Those helped me a lot in understanding how the workbench modules function.
Re: project structure and database
TemplatePyMod just what I need. Thank you!
encoding and QDialogs
I have two more question.
1. I I noticed strange behavior dialogues inside my widget. When I run it separately - dialog works. Inside freeCAD - no. Does FreeCAD puts any restrictions?
this is my code:
2. And encoding problem. ToolTip for my tools.py file doesn't work with cyrillic symbols.
I used getpreferredencoding in console and saw it was ascii. I changed locale end now
>>> locale.getpreferredencoding()
'cp1251'
but it still doesn't work. But when i change # -*- coding: utf-8 -*- to other coding symbols are also changing, but not the ones that I need.
Ui from QtDesigner works ok.
1. I I noticed strange behavior dialogues inside my widget. When I run it separately - dialog works. Inside freeCAD - no. Does FreeCAD puts any restrictions?
this is my code:
Code: Select all
...
QtCore.QObject.connect(self.SaveBtn, QtCore.SIGNAL(_fromUtf8("clicked()")), self.saveFile)
...
def saveFile(self):
filename = QtGui.QFileDialog.getSaveFileName(None, 'Save File', os.getenv('HOME'))
f = open(filename, 'w')
filedata = self.textEdit.toPlainText()
f.write(filedata)
f.close()
...
app = QtGui.QApplication
FCmw = app.activeWindow() # I also tried mw = FreeCADGui.getMainWindow(), but it couses name error
redactor = QtGui.QDockWidget()
redactor.ui = my_ui()
redactor.ui.setupUi(redactor) # setup the ui
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea, redactor)
>>> locale.getpreferredencoding()
'cp1251'
but it still doesn't work. But when i change # -*- coding: utf-8 -*- to other coding symbols are also changing, but not the ones that I need.
Ui from QtDesigner works ok.
- Attachments
-
- f2.PNG (1.01 KiB) Viewed 3204 times
Re: project structure and database
It is hard to know what is wrong, but normally it should work. FreeCAD dialogs usually can display non-ascii charaters without problems. Maybe make sure everything is always utf-8? It's the best way to avoid encoding problems... In any case, if your dialog file is encoded in utf-8 your qt preferred encoding inside freecad should also be utf-8, I think.
Re: project structure and database
All my python files start with # -*- coding: utf-8 -*-. That should be enough for it, yes?yorik wrote:... Maybe make sure everything is always utf-8?
Maybe this is my Windows 7 problem. Thank you!