Jump to content

How to retrieve the "currency" symbol


GregValiant
Go to solution Solved by ahoeben,

Recommended Posts

Posted · How to retrieve the "currency" symbol

What I've tried and hasn't worked are variations on this:


from UM.Preferences import Preferences

 

currency_symbol = Preferences.getValue("cura/currency", "value")

 

I often get:

AttributeError: 'str' object has no attribute '_findPreference'

 

If someone could take a moment to help an old man across the street he'd be much obliged.

 

  • Link to post
    Share on other sites

    • Solution
    Posted · How to retrieve the "currency" symbol

    Try this:
     

    from UM.Application import Application
    
    Application.getInstance().getPreferences().getValue("cura/currency")

     

    Preferences is the class, Application.getInstance().getPreferences() returns the single instance of that class that Cura creates. In python, if you call a method of an instance, python "inserts" a reference to the instance as the first argument. Running getValue directly on the class instead of on an instance of the class means that the reference to the class ("self") does not get passed to the method, and instead the string "cura/currency" gets passed as the argument for "self". 

     

    Will you be able to get back to your side of the street later? Or are you planning to stay on this side?

    • Like 1
    Link to post
    Share on other sites

    Posted · How to retrieve the "currency" symbol

    Thank you kind sir.  That did it.  I can rest quietly on this bench now.

    As for re-crossing I may require help.  I had thought I was crossing Python Street when in reality it is a freakin' 16 lane boulevard and I'm wearing a blindfold.

     

    The fore-slash in the name just wasn't fair.

  • Link to post
    Share on other sites

    • 2 weeks later...
    Posted · How to retrieve the "currency" symbol

    Ok @ahoeben I'm trying to get back across the autobahn.

     

    I'm working on a post-processor and I want to use the extruder_count to enable/disable a setting upon load.

    This requires getting the extruder_count before the settings load and then something like:

    "enabled":  extruder_count >1 ".

     

    I have made numerous tries.  I believe am now familiar with every error code that Python and QML can throw.  What I have not been able to do is to disable the @#$% checkbox if there is only 1 extruder.

     

    Any help would be appreciated.

     

     

     

     

  • Link to post
    Share on other sites

    Posted · How to retrieve the "currency" symbol

    Have you tried just using the machine_extruder_count variable in the enabled property?

     

    "enabled": "machine_extruder_count > 1"

     

     

  • Link to post
    Share on other sites

    Posted · How to retrieve the "currency" symbol
    7 hours ago, ahoeben said:

    Have you tried just using the machine_extruder_count

    No, silly goose! Using setting names as variables does not work in postprocessing scripts!

  • Link to post
    Share on other sites

    Posted · How to retrieve the "currency" symbol

    Just to settle this thread...your "shadow setting" works.

     

    I have once again successfully crossed the highway.

    • Like 1
    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 20 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...