Commit 38b899b277c0729dce6b8fb3fc240d8f0f6129ba
1 parent
3d07ca34
Exists in
master
and in
68 other branches
ENH: Credits to translators and artist
Showing
1 changed file
with
154 additions
and
16 deletions
Show diff stats
invesalius/gui/dialogs.py
| @@ -231,16 +231,6 @@ def ShowSaveAsProjectDialog(default_filename=None): | @@ -231,16 +231,6 @@ def ShowSaveAsProjectDialog(default_filename=None): | ||
| 231 | os.chdir(current_dir) | 231 | os.chdir(current_dir) |
| 232 | return filename | 232 | return filename |
| 233 | 233 | ||
| 234 | - | ||
| 235 | - | ||
| 236 | - | ||
| 237 | - | ||
| 238 | - | ||
| 239 | - | ||
| 240 | - | ||
| 241 | - | ||
| 242 | - | ||
| 243 | - | ||
| 244 | class MessageDialog(wx.Dialog): | 234 | class MessageDialog(wx.Dialog): |
| 245 | def __init__(self, message): | 235 | def __init__(self, message): |
| 246 | pre = wx.PreDialog() | 236 | pre = wx.PreDialog() |
| @@ -395,6 +385,144 @@ def NewMask(): | @@ -395,6 +385,144 @@ def NewMask(): | ||
| 395 | return dlg.GetValue() | 385 | return dlg.GetValue() |
| 396 | return None | 386 | return None |
| 397 | 387 | ||
| 388 | +class NewMaskDialog(wx.Dialog): | ||
| 389 | + def __init__(self, | ||
| 390 | + parent=None, | ||
| 391 | + ID=-1, | ||
| 392 | + title="InVesalius 3", | ||
| 393 | + size=wx.DefaultSize, | ||
| 394 | + pos=wx.DefaultPosition, | ||
| 395 | + style=wx.DEFAULT_DIALOG_STYLE, | ||
| 396 | + useMetal=False): | ||
| 397 | + import constants as const | ||
| 398 | + import data.surface as surface | ||
| 399 | + import project as prj | ||
| 400 | + | ||
| 401 | + # Instead of calling wx.Dialog.__init__ we precreate the dialog | ||
| 402 | + # so we can set an extra style that must be set before | ||
| 403 | + # creation, and then we create the GUI object using the Create | ||
| 404 | + # method. | ||
| 405 | + pre = wx.PreDialog() | ||
| 406 | + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) | ||
| 407 | + pre.Create(parent, ID, title, pos, (500,300), style) | ||
| 408 | + | ||
| 409 | + # This next step is the most important, it turns this Python | ||
| 410 | + # object into the real wrapper of the dialog (instead of pre) | ||
| 411 | + # as far as the wxPython extension is concerned. | ||
| 412 | + self.PostCreate(pre) | ||
| 413 | + | ||
| 414 | + self.CenterOnScreen() | ||
| 415 | + | ||
| 416 | + # This extra style can be set after the UI object has been created. | ||
| 417 | + if 'wxMac' in wx.PlatformInfo and useMetal: | ||
| 418 | + self.SetExtraStyle(wx.DIALOG_EX_METAL) | ||
| 419 | + | ||
| 420 | + self.CenterOnScreen() | ||
| 421 | + | ||
| 422 | + # LINE 1: Surface name | ||
| 423 | + | ||
| 424 | + label_surface = wx.StaticText(self, -1, _("New mask name:")) | ||
| 425 | + | ||
| 426 | + default_name = const.SURFACE_NAME_PATTERN %(surface.Surface.general_index+2) | ||
| 427 | + text = wx.TextCtrl(self, -1, "", size=(80,-1)) | ||
| 428 | + text.SetHelpText(_("Name the mask to be created")) | ||
| 429 | + text.SetValue(default_name) | ||
| 430 | + self.text = text | ||
| 431 | + | ||
| 432 | + # LINE 2: Mask of reference | ||
| 433 | + | ||
| 434 | + # Informative label | ||
| 435 | + label_mask = wx.StaticText(self, -1, _("Threshold preset:")) | ||
| 436 | + | ||
| 437 | + # Retrieve existing masks | ||
| 438 | + project = prj.Project() | ||
| 439 | + thresh_list = project.threshold_modes.keys() | ||
| 440 | + thresh_list.sort() | ||
| 441 | + default_index = proj.threshold_modes.get_key(_("Default")) | ||
| 442 | + self.thresh_list = thresh_list | ||
| 443 | + | ||
| 444 | + # Mask selection combo | ||
| 445 | + combo_mask = wx.ComboBox(self, -1, "", choices= self.thresh_list, | ||
| 446 | + style=wx.CB_DROPDOWN|wx.CB_READONLY) | ||
| 447 | + combo_mask.SetSelection(len(self.thresh_list)-1) | ||
| 448 | + if sys.platform != 'win32': | ||
| 449 | + combo_mask.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
| 450 | + self.combo_mask = combo_mask | ||
| 451 | + | ||
| 452 | + # LINE 3: Surface quality | ||
| 453 | + label_quality = wx.StaticText(self, -1, _("Surface quality:")) | ||
| 454 | + | ||
| 455 | + choices = const.SURFACE_QUALITY_LIST, | ||
| 456 | + style = wx.CB_DROPDOWN|wx.CB_READONLY | ||
| 457 | + combo_quality = wx.ComboBox(self, -1, "", | ||
| 458 | + choices= choices, | ||
| 459 | + style=style) | ||
| 460 | + combo_quality.SetSelection(3) | ||
| 461 | + if sys.platform != 'win32': | ||
| 462 | + combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
| 463 | + self.combo_quality = combo_quality | ||
| 464 | + | ||
| 465 | + | ||
| 466 | + # OVERVIEW | ||
| 467 | + # Sizer that joins content above | ||
| 468 | + flag_link = wx.EXPAND|wx.GROW|wx.ALL | ||
| 469 | + flag_button = wx.ALL | wx.EXPAND| wx.GROW | ||
| 470 | + | ||
| 471 | + fixed_sizer = wx.FlexGridSizer(rows=2, cols=2, hgap=10, vgap=0) | ||
| 472 | + fixed_sizer.AddGrowableCol(0, 1) | ||
| 473 | + fixed_sizer.AddMany([ (label_surface, 1, flag_link, 5), | ||
| 474 | + (text, 1, flag_button, 2), | ||
| 475 | + (label_mask, 1, flag_link, 5), | ||
| 476 | + (combo_mask, 0, flag_button, 1), | ||
| 477 | + (label_quality, 1, flag_link, 5), | ||
| 478 | + (combo_quality, 0, flag_button, 1)]) | ||
| 479 | + | ||
| 480 | + | ||
| 481 | + # LINES 4 and 5: Checkboxes | ||
| 482 | + check_box_holes = wx.CheckBox(self, -1, _("Fill holes")) | ||
| 483 | + check_box_holes.SetValue(True) | ||
| 484 | + self.check_box_holes = check_box_holes | ||
| 485 | + check_box_largest = wx.CheckBox(self, -1, _("Keep largest region")) | ||
| 486 | + self.check_box_largest = check_box_largest | ||
| 487 | + | ||
| 488 | + # LINE 6: Buttons | ||
| 489 | + | ||
| 490 | + btn_ok = wx.Button(self, wx.ID_OK) | ||
| 491 | + btn_ok.SetDefault() | ||
| 492 | + btn_cancel = wx.Button(self, wx.ID_CANCEL) | ||
| 493 | + | ||
| 494 | + btnsizer = wx.StdDialogButtonSizer() | ||
| 495 | + btnsizer.AddButton(btn_ok) | ||
| 496 | + btnsizer.AddButton(btn_cancel) | ||
| 497 | + btnsizer.Realize() | ||
| 498 | + | ||
| 499 | + # OVERVIEW | ||
| 500 | + # Merge all sizers and checkboxes | ||
| 501 | + sizer = wx.BoxSizer(wx.VERTICAL) | ||
| 502 | + sizer.Add(fixed_sizer, 0, wx.TOP|wx.RIGHT|wx.LEFT|wx.GROW|wx.EXPAND, 20) | ||
| 503 | + sizer.Add(check_box_holes, 0, wx.RIGHT|wx.LEFT, 30) | ||
| 504 | + sizer.Add(check_box_largest, 0, wx.RIGHT|wx.LEFT, 30) | ||
| 505 | + sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.ALL, 10) | ||
| 506 | + | ||
| 507 | + self.SetSizer(sizer) | ||
| 508 | + sizer.Fit(self) | ||
| 509 | + | ||
| 510 | + def GetValue(self): | ||
| 511 | + mask_index = self.combo_mask.GetSelection() | ||
| 512 | + surface_name = self.text.GetValue() | ||
| 513 | + quality = const.SURFACE_QUALITY_LIST[self.combo_quality.GetSelection()] | ||
| 514 | + fill_holes = self.check_box_holes.GetValue() | ||
| 515 | + keep_largest = self.check_box_largest.GetValue() | ||
| 516 | + return (mask_index, surface_name, quality, fill_holes, keep_largest) | ||
| 517 | + | ||
| 518 | + | ||
| 519 | + | ||
| 520 | + | ||
| 521 | + | ||
| 522 | + | ||
| 523 | + | ||
| 524 | + | ||
| 525 | + | ||
| 398 | def InexistentPath(path): | 526 | def InexistentPath(path): |
| 399 | msg = _("%s does not exist.")%(path) | 527 | msg = _("%s does not exist.")%(path) |
| 400 | if sys.platform == 'darwin': | 528 | if sys.platform == 'darwin': |
| @@ -473,11 +601,16 @@ def ShowAboutDialog(parent): | @@ -473,11 +601,16 @@ def ShowAboutDialog(parent): | ||
| 473 | "Paulo Henrique Junqueira Amorim", | 601 | "Paulo Henrique Junqueira Amorim", |
| 474 | "Thiago Franco de Moraes"] | 602 | "Thiago Franco de Moraes"] |
| 475 | #info.DocWriters = | 603 | #info.DocWriters = |
| 476 | - info.Translators = ["Alex P. Natsios (GR)", | ||
| 477 | - "Andreas Loupasakis (GR)", | ||
| 478 | - "Dimitris Glezos (GR)", | 604 | + info.Translators = ["Alex P. Natsios (EL)", |
| 605 | + "Andreas Loupasakis (EL)", | ||
| 606 | + "Cheng-Chia Tseng (ZH)", | ||
| 607 | + "Dimitris Glezos (EL)", | ||
| 479 | u"Frédéric Lopez (FR)", | 608 | u"Frédéric Lopez (FR)", |
| 480 | - "Nikos Korkakakis (GR)"] | 609 | + "J. Javier de Lima Moreno (ES)" |
| 610 | + "Nikos Korkakakis (EL)", | ||
| 611 | + "Sebastian Hilbert (FR)"] | ||
| 612 | + | ||
| 613 | + info.Artists = ["Otavio Henrique Junqueira Amorim"] | ||
| 481 | 614 | ||
| 482 | # Then we call wx.AboutBox giving its info object | 615 | # Then we call wx.AboutBox giving its info object |
| 483 | wx.AboutBox(info) | 616 | wx.AboutBox(info) |
| @@ -518,6 +651,8 @@ class NewSurfaceDialog(wx.Dialog): | @@ -518,6 +651,8 @@ class NewSurfaceDialog(wx.Dialog): | ||
| 518 | # as far as the wxPython extension is concerned. | 651 | # as far as the wxPython extension is concerned. |
| 519 | self.PostCreate(pre) | 652 | self.PostCreate(pre) |
| 520 | 653 | ||
| 654 | + self.CenterOnScreen() | ||
| 655 | + | ||
| 521 | # This extra style can be set after the UI object has been created. | 656 | # This extra style can be set after the UI object has been created. |
| 522 | if 'wxMac' in wx.PlatformInfo and useMetal: | 657 | if 'wxMac' in wx.PlatformInfo and useMetal: |
| 523 | self.SetExtraStyle(wx.DIALOG_EX_METAL) | 658 | self.SetExtraStyle(wx.DIALOG_EX_METAL) |
| @@ -557,8 +692,11 @@ class NewSurfaceDialog(wx.Dialog): | @@ -557,8 +692,11 @@ class NewSurfaceDialog(wx.Dialog): | ||
| 557 | # LINE 3: Surface quality | 692 | # LINE 3: Surface quality |
| 558 | label_quality = wx.StaticText(self, -1, _("Surface quality:")) | 693 | label_quality = wx.StaticText(self, -1, _("Surface quality:")) |
| 559 | 694 | ||
| 560 | - combo_quality = wx.ComboBox(self, -1, "", choices= const.SURFACE_QUALITY_LIST, | ||
| 561 | - style=wx.CB_DROPDOWN|wx.CB_READONLY) | 695 | + choices = const.SURFACE_QUALITY_LIST |
| 696 | + style = wx.CB_DROPDOWN|wx.CB_READONLY | ||
| 697 | + combo_quality = wx.ComboBox(self, -1, "", | ||
| 698 | + choices= choices, | ||
| 699 | + style=style) | ||
| 562 | combo_quality.SetSelection(3) | 700 | combo_quality.SetSelection(3) |
| 563 | if sys.platform != 'win32': | 701 | if sys.platform != 'win32': |
| 564 | combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | 702 | combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |