MoleditPy 1.16.0a2__py3-none-any.whl → 1.16.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ from PyQt6.QtGui import QFont, QColor
4
4
  from rdkit import Chem
5
5
 
6
6
  #Version
7
- VERSION = '1.16.0a2'
7
+ VERSION = '1.16.1'
8
8
 
9
9
  ATOM_RADIUS = 18
10
10
  BOND_OFFSET = 3.5
@@ -51,27 +51,52 @@ def detect_system_dark_mode():
51
51
  macOS (defaults read), and GNOME/GTK-based Linux (gsettings). Return
52
52
  None if no reliable information is available.
53
53
  """
54
+ # Delegate detailed OS detection to `detect_system_theme` and map
55
+ # 'dark' -> True, 'light' -> False. This avoids duplicating the
56
+ # registry and subprocess calls in two places.
57
+ theme = detect_system_theme()
58
+ if theme == 'dark':
59
+ return True
60
+ if theme == 'light':
61
+ return False
62
+ return None
63
+
64
+ def detect_system_theme():
65
+ """OSの優先テーマ設定を 'dark', 'light', または None として返す。
66
+
67
+ This is a best-effort, cross-platform check.
68
+ """
54
69
  try:
55
- # Windows: read registry AppsUseLightTheme (0 = dark, 1 = light)
70
+ # Windows: AppsUseLightTheme (0 = dark, 1 = light)
56
71
  if platform.system() == 'Windows' and winreg is not None:
57
72
  try:
58
73
  with winreg.OpenKey(winreg.HKEY_CURRENT_USER,
59
74
  r'Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') as k:
60
75
  val, _ = winreg.QueryValueEx(k, 'AppsUseLightTheme')
61
- return False if int(val) == 0 else True
76
+ return 'dark' if int(val) == 0 else 'light'
62
77
  except Exception:
63
78
  pass
64
79
 
65
- # macOS: 'defaults read -g AppleInterfaceStyle' returns 'Dark' in dark mode
80
+ # macOS: 'defaults read -g AppleInterfaceStyle'
66
81
  if platform.system() == 'Darwin':
82
+ return 'light'
83
+ '''
67
84
  try:
68
- p = subprocess.run(['defaults', 'read', '-g', 'AppleInterfaceStyle'], capture_output=True, text=True)
69
- if p.returncode == 0 and p.stdout.strip().lower() == 'dark':
70
- return True
71
- # Key absence implies light mode
72
- return False
85
+ # 'defaults read ...' が成功すればダークモード
86
+ p = subprocess.run(
87
+ ['defaults', 'read', '-g', 'AppleInterfaceStyle'],
88
+ capture_output=True, text=True, check=True, encoding='utf-8'
89
+ )
90
+ if p.stdout.strip().lower() == 'dark':
91
+ return 'dark'
92
+
93
+ except subprocess.CalledProcessError:
94
+ # コマンド失敗 (キーが存在しない) = ライトモード
95
+ return 'light'
73
96
  except Exception:
97
+ # その他のエラー
74
98
  pass
99
+ '''
75
100
 
76
101
  # Linux / GNOME: try color-scheme gsetting; fallback to gtk-theme detection
77
102
  if platform.system() == 'Linux':
@@ -80,16 +105,16 @@ def detect_system_dark_mode():
80
105
  if p.returncode == 0:
81
106
  out = p.stdout.strip().strip("'\n ")
82
107
  if 'dark' in out.lower():
83
- return True
108
+ return 'dark'
84
109
  if 'light' in out.lower():
85
- return False
110
+ return 'light'
86
111
  except Exception:
87
112
  pass
88
113
 
89
114
  try:
90
115
  p = subprocess.run(['gsettings', 'get', 'org.gnome.desktop.interface', 'gtk-theme'], capture_output=True, text=True)
91
116
  if p.returncode == 0 and '-dark' in p.stdout.lower():
92
- return True
117
+ return 'dark'
93
118
  except Exception:
94
119
  pass
95
120
  except Exception:
@@ -213,8 +238,8 @@ class MainWindowMainInit(object):
213
238
  self.atom_selection_mode = False
214
239
  self.selected_atom_actors = []
215
240
 
216
- # 3D編集用の原子選択状態
217
- self.selected_atoms_3d = set() # 3Dビューで選択された原子のインデックス
241
+ # 3D編集用の原子選択状態 (3Dビューで選択された原子のインデックス)
242
+ self.selected_atoms_3d = set()
218
243
 
219
244
  # 3D編集ダイアログの参照を保持
220
245
  self.active_3d_dialogs = []
@@ -472,11 +497,10 @@ class MainWindowMainInit(object):
472
497
  def _icon_foreground_color():
473
498
  """Return a QColor for icon foreground.
474
499
 
475
- NOTE: this application inverts the usual foreground mapping so icons
476
- will be the *opposite* color to the background (i.e., black on dark
477
- backgrounds, white on light backgrounds). This intentionally reverses
478
- the previous behavior so button icons don't blend into the 3D-view
479
- background. Priority: explicit setting in 'icon_foreground' -> OS
500
+ NOTE: choose icon foreground to contrast against the background
501
+ (i.e., white on dark backgrounds, black on light backgrounds). This
502
+ matches common conventions. Priority: explicit setting in
503
+ 'icon_foreground' -> OS theme preference -> configured 3D
480
504
  theme preference -> configured 3D background -> application palette.
481
505
  """
482
506
  try:
@@ -491,9 +515,9 @@ class MainWindowMainInit(object):
491
515
  # 1) Prefer the system/OS dark-mode preference if available.
492
516
  try:
493
517
  os_pref = detect_system_dark_mode()
494
- # Invert the color so in dark-pref OS we return black, in light we return white
518
+ # Standard mapping: dark -> white, light -> black
495
519
  if os_pref is not None:
496
- return QColor('#000000') if os_pref else QColor('#FFFFFF')
520
+ return QColor('#FFFFFF') if os_pref else QColor('#000000')
497
521
  except Exception:
498
522
  pass
499
523
 
@@ -505,8 +529,8 @@ class MainWindowMainInit(object):
505
529
  bg = QColor(bg_hex)
506
530
  if bg.isValid():
507
531
  lum = 0.2126 * bg.redF() + 0.7152 * bg.greenF() + 0.0722 * bg.blueF()
508
- # Inverted: return black on dark (lum<0.5), white on light
509
- return QColor('#000000') if lum < 0.5 else QColor('#FFFFFF')
532
+ # Return white on dark (lum<0.5), black on light
533
+ return QColor('#FFFFFF') if lum < 0.5 else QColor('#000000')
510
534
  except Exception:
511
535
  pass
512
536
 
@@ -515,8 +539,8 @@ class MainWindowMainInit(object):
515
539
  # palette.window() returns a QBrush; call color()
516
540
  window_bg = pal.window().color()
517
541
  lum = 0.2126 * window_bg.redF() + 0.7152 * window_bg.greenF() + 0.0722 * window_bg.blueF()
518
- # Inverted mapping for palette fallback
519
- return QColor('#000000') if lum < 0.5 else QColor('#FFFFFF')
542
+ # Palette-based mapping: white on dark palette background
543
+ return QColor('#FFFFFF') if lum < 0.5 else QColor('#000000')
520
544
  except Exception:
521
545
  return QColor('#000000')
522
546
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MoleditPy
3
- Version: 1.16.0a2
3
+ Version: 1.16.1
4
4
  Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
5
5
  Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/HiroYokoyama/python_molecular_editor
@@ -15,7 +15,6 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
- Classifier: License :: OSI Approved :: Apache Software License
19
18
  Requires-Python: <3.14,>=3.9
20
19
  Description-Content-Type: text/markdown
21
20
  Requires-Dist: numpy
@@ -12,7 +12,7 @@ moleditpy/modules/bond_item.py,sha256=zjQHa4vb8xhS9B7cYPRM0nak-f7lr5NQ1uAj_J78ah
12
12
  moleditpy/modules/bond_length_dialog.py,sha256=xlx-bU3tVeLfShdVRw6_Geo5Gl9mztlIfTdT9tJ6WMA,14579
13
13
  moleditpy/modules/calculation_worker.py,sha256=detE48BW08a2tvmKjMgz8zCShgARzsRH-ABmWrPcqZA,42055
14
14
  moleditpy/modules/color_settings_dialog.py,sha256=h4AOKU8dCTenecI8zOM9GfnmKDm7jfe5C4Fa23Budvs,15205
15
- moleditpy/modules/constants.py,sha256=Tqlh-TYf2Lxar5jSjw26MNTSuByatz1l_OWvZxjvAD8,4436
15
+ moleditpy/modules/constants.py,sha256=LXRej--b5v1JadEX63TDXvO8oalwVNWArkz732Q_-ME,4434
16
16
  moleditpy/modules/constrained_optimization_dialog.py,sha256=MlWnPze0JJvnqmHx9n3qZWG_h-2kZymT0PQ6lALbCro,29861
17
17
  moleditpy/modules/custom_interactor_style.py,sha256=K_uGM6FezY0kZ3zPqoR6f0nowG40ytt-L4UCAbPlwGM,38184
18
18
  moleditpy/modules/custom_qt_interactor.py,sha256=6mzaVb3Mhp-4nryG5AraEvPPgBJpotrzVYwrpCAKmVo,2186
@@ -25,7 +25,7 @@ moleditpy/modules/main_window_dialog_manager.py,sha256=5WU6mFABB0aI4XCywP-cLFPkN
25
25
  moleditpy/modules/main_window_edit_3d.py,sha256=FStBWVeDVAM2MoO-JCTjPM-G7iT8QZUHxsb0dS4MEAI,19553
26
26
  moleditpy/modules/main_window_edit_actions.py,sha256=8tR0rYfgWYgdKTxBP4snzpxhiD2DExSKyf4jzSWb6sE,64598
27
27
  moleditpy/modules/main_window_export.py,sha256=f_Z4qVYKBTe06lGTFqjd3deluUdkQvHhZYa81h7UpBM,34465
28
- moleditpy/modules/main_window_main_init.py,sha256=ujRy4Rl7A5YefAbdmhzXKEofX5wOitBoAthB75mI0GM,74513
28
+ moleditpy/modules/main_window_main_init.py,sha256=xAstCr__601hkbb1IpqpQKUFTSS6quYe66sBOgqJjkc,75228
29
29
  moleditpy/modules/main_window_molecular_parsers.py,sha256=8JAIgr1axzmJqX_Ue-Adkl8e_8B2Th9yutQbau8EEWQ,43401
30
30
  moleditpy/modules/main_window_project_io.py,sha256=2ArkW23L4ahQIiktCCXlNsJphU0awO5YzJGihIJsn1c,17021
31
31
  moleditpy/modules/main_window_string_importers.py,sha256=yrZblvPG840qnqVEJf__XVfNnWl_r3vt68Abfs2aYDQ,10674
@@ -47,8 +47,8 @@ moleditpy/modules/zoomable_view.py,sha256=ZgAmmWXIKtx7AhMjs6H6PCyvb_kpYuankf8Uxs
47
47
  moleditpy/modules/assets/icon.icns,sha256=wD5R6-Vw7K662tVKhu2E1ImN0oUuyAP4youesEQsn9c,139863
48
48
  moleditpy/modules/assets/icon.ico,sha256=RfgFcx7-dHY_2STdsOQCQziY5SNhDr3gPnjO6jzEDPI,147975
49
49
  moleditpy/modules/assets/icon.png,sha256=kCFN1WacYIdy0GN6SFEbNA00ef39pCczBnFdkkBI8Bs,147110
50
- moleditpy-1.16.0a2.dist-info/METADATA,sha256=txWbudtlNWevsuxk2M1wAWZVBPe_Y6_J_1mqhErQYH4,17422
51
- moleditpy-1.16.0a2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
- moleditpy-1.16.0a2.dist-info/entry_points.txt,sha256=yH1h9JjALhok1foXT3-hYrC4ufoZt8b7oiBcsdnGNNM,54
53
- moleditpy-1.16.0a2.dist-info/top_level.txt,sha256=ARICrS4ihlPXqywlKl6o-oJa3Qz3gZRWu_VZsQ3_c44,10
54
- moleditpy-1.16.0a2.dist-info/RECORD,,
50
+ moleditpy-1.16.1.dist-info/METADATA,sha256=lNUaucVX0UqqAwtAlXYY9qw0re5uP49MxPp3vCH5pXQ,17356
51
+ moleditpy-1.16.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
+ moleditpy-1.16.1.dist-info/entry_points.txt,sha256=yH1h9JjALhok1foXT3-hYrC4ufoZt8b7oiBcsdnGNNM,54
53
+ moleditpy-1.16.1.dist-info/top_level.txt,sha256=ARICrS4ihlPXqywlKl6o-oJa3Qz3gZRWu_VZsQ3_c44,10
54
+ moleditpy-1.16.1.dist-info/RECORD,,