5
$\begingroup$

I'm wondering how can I make a messagebox with the fields username and password to appear when blender is opened, and depending on the user's credentials a different startup file will start. I'm thinking that this can be done where the credentials will be staticly saved within a python script which will run when launching blender like:

if username == 'user1' and password == 'user1pass':
 open starup file1
elif username is 'user2' and password is 'user2pass':
 open starup file2
else:
 display a message saying "sorry not a correct user" and make the user try loginning again

Any thoughts please how this can be done?

$\endgroup$
  • 1
    $\begingroup$ What are you expecting to get as an answer? This is a very complicated subject and, furthermore, there are many ways to do it. The pseudocode that you posted is not really showing that you tried anything. $\endgroup$ – JakeD Oct 18 '16 at 0:18
  • $\begingroup$ @pycoder I didn't post what I tried because I don't know from where I should start or how this can be done. $\endgroup$ – Tak Oct 18 '16 at 0:59
  • $\begingroup$ @pycoder maybe he have no idea how to ask, because he have no enough knowledge about this. In my opinion this is not bad idea - If this allow choose different User preferences (including sets of add-ons) for different kind of work and different Startup File on start, in best case from Splash screen. I thing this can be useful. Only I'm not sure whether it is worth the effort. $\endgroup$ – Shubol3D Oct 18 '16 at 8:17
  • $\begingroup$ @Shubol3D thank you very much. The reason my question wasn't detailed enough because as you mentioned I just have no enough knowledge how this can be done. And yes, I want to choose a different startup file on the start. $\endgroup$ – Tak Oct 18 '16 at 9:47
  • $\begingroup$ So you are basically asking, "How can I add custom properties and operators to the splash screen?" $\endgroup$ – JakeD Oct 18 '16 at 11:56
1
$\begingroup$

This question is too open-ended to be answered in detail, so I'll answer generally. Before we talk about how to create such a solution, there are some issues with what you are trying to do.

First, there is no "security" offered by what you are doing, so there is no reason to ask for a password. You can simply let the user choose from a list of startup profiles. If you wish to provide some kind of security, you need to use your operating system's user accounts. You said you are using windows, so you would want to create a separate windows account for each user.

Second, it's strange to be asking for "username", since the startup file is only a set of presets for new projects. If the user saves his work, and loads it later, loading the file will overwrite the startup file information. Choosing a different startup file would more likely be used to choose different "configurations" of blender, for different types of tasks.

Therefore, the only sensible way to use the UI you are suggesting is actually to present a list of "startup configurations" and let the user pick between them. The following will explain one way you might do that.

You will need to create some custom UI for your startup-selector using python. I don't believe you can modify the splash screen from python, so I would do this by making a custom page in the user-preferences UI. This custom page will contain your UI and the logic to load the proper startup file. (See scripts/startup/bl_ui/space_userpref.py)

Once you have your custom UI for picking a startup file and loading it, you can make a startup file which loads this when blender starts. Configure blender the way you want, with only one view on the screen, showing the user-pref space, with your custom space-chooser showing. Then do File->Save Startup File. Now this will show every time blender is launched.

That should give you a startup-file selector on launch.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.