Yes, I understood that.triplus wrote:Yes but you don't have to change to English language. Just use the correct terms as seen in menu in your language instead.
thank you,
Renato
Yes, I understood that.triplus wrote:Yes but you don't have to change to English language. Just use the correct terms as seen in menu in your language instead.
Code: Select all
# ==============================
name = "Wireframe"
# ==============================
from PySide import QtGui
mw = FreeCADGui.getMainWindow()
for i in mw.findChildren(QtGui.QAction):
if i.text() == name.decode("UTF-8"):
i.activate(QtGui.QAction.Trigger)
Code: Select all
# ==============================
nameA = "Wireframe"
nameB = "As is"
# ==============================
from PySide import QtGui
mw = FreeCADGui.getMainWindow()
contextA = "Std_DrawStyle"
nameA = (QtGui.QApplication.translate(contextA, nameA, None)).encode("UTF-8")
contextB = "Std_DrawStyle"
nameB = (QtGui.QApplication.translate(contextB, nameB, None)).encode("UTF-8")
for i in mw.findChildren(QtGui.QAction):
if i.text() == nameA.decode("UTF-8"):
actionA = i
elif i.text() == nameB.decode("UTF-8"):
actionB = i
else:
pass
if actionA.isChecked():
actionB.activate(QtGui.QAction.Trigger)
else:
actionA.activate(QtGui.QAction.Trigger)
nevertheless, I always get a# -*- coding: utf-8 -*-
#
#
# Macro: Toggle Draw Style
#
# This macros allows the user to switch between different Drawstyles by clicking on
# the button of a Macro in a toolbar.
#
# initial code: triplus
# macro-isation: piffpoof
#
# This macro switches (or toggles) between 2 selected styles from the Drawstyle menu.
# As written the macro toggles between "WireFrame" and "As is".
# Immediately below this text is a list of the legal values for the Drawstyle menu.
# The first 2 lines of executable code are of the form "DrawstyleA = " followed by
# the 2nd line which is of the form "DrawstyleB = ".
# These 2 lines specify which of the Drawstyle values the macro will toggle between.
# Drawstyle "As is" is the system default and so is specified as the first drawstyle.
# The second line specifies which drawstyle will be toggled to and from.
# Any of the legal values may be used, so if, for example, it is desired to toggle between
# the Shaded and Points drawstyles, then the 2 lines of code would be modified to be:
#
# drawstyleA = "Shaded"
# drawstyleB = "Points"
#
# but remember that the hash signs ('#') are not to be present on the executable lines.
#
###Legal Values for Drawstyle###
#
# "As is"
# "FlatLines"
# "Shaded
# "Wireframe"
# "Points"
#
################################
from PySide import QtGui
# Constant definitions
drawstyleA = "As is"
drawstyleB = "Wireframe"
# code ***********************************************************************************
mw = FreeCADGui.getMainWindow()
for i in mw.findChildren(QtGui.QAction):
if i.text() == drawstyleA.decode("UTF-8"):
actionA = i
elif i.text() == drawstyleB.decode("UTF-8"):
actionB = i
else:
pass
if actionA.isChecked():
actionB.activate(QtGui.QAction.Trigger)
else:
actionA.activate(QtGui.QAction.Trigger)
Code: Select all
drawstyleA = "As is"
drawstyleB = "Wireframe"
Code: Select all
drawstyleA = "Original"
drawstyleB = "Drahtgitter"
Code: Select all
# ==============================
nameA = "Drahtgitter"
nameB = "Schattiert"
# ==============================
from PySide import QtGui
mw = FreeCADGui.getMainWindow()
contextA = "Std_DrawStyle"
nameA = (QtGui.QApplication.translate(contextA, nameA, None)).encode("UTF-8")
contextB = "Std_DrawStyle"
nameB = (QtGui.QApplication.translate(contextB, nameB, None)).encode("UTF-8")
for i in mw.findChildren(QtGui.QAction):
if i.text() == nameA.decode("UTF-8"):
actionA = i
elif i.text() == nameB.decode("UTF-8"):
actionB = i
else:
pass
if actionA.isChecked():
actionB.activate(QtGui.QAction.Trigger)
else:
actionA.activate(QtGui.QAction.Trigger)
Code: Select all
nameA = "Drahtgitter"
nameB = "Schattiert"