-#!/usr/bin/env python\r
+#!/usr/bin/env python\r
# -*- coding: utf-8 -*-\r
\r
#Pydun.py - mapping tool\r
#copyright (c) 2013 WATAHIKI Hiroyuki\r
-#url: http://sourceforge.jp/projects/pydun/\r
+#url: http://osdn.jp/projects/pydun/\r
#email: hrwatahiki at gmail.com\r
+#twitter: @hrwatahiki\r
+#blog: http://hrwatahiki.blogspot.jp/\r
\r
\r
import sys\r
import os.path\r
-import codecs\r
import locale\r
-import urllib\r
+import urllib.request, urllib.parse, urllib.error\r
import xml.etree.ElementTree\r
import webbrowser\r
from PySide import QtCore, QtGui\r
_mapimages = None\r
_undomanager = None\r
\r
-projecturl = "http://sourceforge.jp/projects/pydun/"\r
-projectrssurl = "http://sourceforge.jp/projects/pydun/releases/rss"\r
-projectversion = "1.0.6"\r
+projecturl = "http://osdn.jp/projects/pydun/"\r
+projectrssurl = "http://osdn.jp/projects/pydun/releases/rss"\r
+projectversion = "1.1.0"\r
\r
\r
class MainWindow(QtGui.QMainWindow):\r
\r
self.new()\r
if len(sys.argv) >= 2:\r
- self.open(unicode(sys.argv[1], locale.getpreferredencoding()))\r
+ self.open(sys.argv[1])\r
\r
self.mainframe = MainFrame(self)\r
self.setCentralWidget(self.mainframe)\r
\r
self.statusbar = QtGui.QStatusBar(self)\r
- self.statusbar.showMessage(u"")\r
+ self.statusbar.showMessage("")\r
self.setStatusBar(self.statusbar)\r
if "windowSize" in config:\r
self.resize(\r
def setmenu(self):\r
global config\r
#File menu\r
- filemenu = self.menuBar().addMenu(u"ファイル(&F)")\r
+ filemenu = self.menuBar().addMenu("ファイル(&F)")\r
\r
- newact = QtGui.QAction(u"新規(&N)", self)\r
+ newact = QtGui.QAction("新規(&N)", self)\r
newact.triggered.connect(self.new_triggered)\r
newact.setShortcut(QtGui.QKeySequence.New)\r
filemenu.addAction(newact)\r
\r
- openact = QtGui.QAction(u"開く(&O)...", self)\r
+ openact = QtGui.QAction("開く(&O)...", self)\r
openact.triggered.connect(self.open_triggered)\r
openact.setShortcut(QtGui.QKeySequence.Open)\r
filemenu.addAction(openact)\r
\r
- saveact = QtGui.QAction(u"上書き保存(&S)", self)\r
+ saveact = QtGui.QAction("上書き保存(&S)", self)\r
saveact.triggered.connect(self.save_triggered)\r
saveact.setShortcut(QtGui.QKeySequence.Save)\r
filemenu.addAction(saveact)\r
\r
- saveasact = QtGui.QAction(u"名前をつけて保存(&A)...", self)\r
+ saveasact = QtGui.QAction("名前をつけて保存(&A)...", self)\r
saveasact.triggered.connect(self.saveas_triggered)\r
saveasact.setShortcut(QtGui.QKeySequence.SaveAs)\r
filemenu.addAction(saveasact)\r
\r
- exitact = QtGui.QAction(u"終了(&E)", self)\r
+ exitact = QtGui.QAction("終了(&E)", self)\r
exitact.triggered.connect(self.exit_triggered)\r
exitact.setShortcut(QtGui.QKeySequence.Quit)\r
filemenu.addAction(exitact)\r
\r
#Edit menu\r
- editmenu = self.menuBar().addMenu(u"編集(&E)")\r
- self.undoact = QtGui.QAction(u"元に戻す(&U)", self)\r
+ editmenu = self.menuBar().addMenu("編集(&E)")\r
+ self.undoact = QtGui.QAction("元に戻す(&U)", self)\r
self.undoact.triggered.connect(self.undo_triggered)\r
self.undoact.setShortcut(QtGui.QKeySequence.Undo)\r
editmenu.addAction(self.undoact)\r
- self.redoact = QtGui.QAction(u"やり直し(&R)", self)\r
+ self.redoact = QtGui.QAction("やり直し(&R)", self)\r
self.redoact.triggered.connect(self.redo_triggered)\r
self.redoact.setShortcut(QtGui.QKeySequence.Redo)\r
editmenu.addAction(self.redoact)\r
editmenu.addSeparator()\r
- setmapsizeact = QtGui.QAction(u"マップのサイズ(&S)", self)\r
+ setmapsizeact = QtGui.QAction("マップのサイズ(&S)", self)\r
setmapsizeact.triggered.connect(self.setmapsize_triggered)\r
editmenu.addAction(setmapsizeact)\r
- setorigineact = QtGui.QAction(u"座標設定(&O)", self)\r
+ setorigineact = QtGui.QAction("座標設定(&O)", self)\r
setorigineact.triggered.connect(self.setorigine_triggered)\r
editmenu.addAction(setorigineact)\r
- wallmenustringact = QtGui.QAction(u"壁メニューに文字を表示する(&W)", self)\r
+ wallmenustringact = QtGui.QAction("壁メニューに文字を表示する(&W)", self)\r
wallmenustringact.setCheckable(True)\r
wallmenustringact.setChecked(config.get("showWallMenuString", False))\r
wallmenustringact.triggered.connect(self.togglewallmenustring_triggered)\r
editmenu.addAction(wallmenustringact)\r
\r
#Help menu\r
- helpmenu = self.menuBar().addMenu(u"ヘルプ(&H)")\r
- tutorialact = QtGui.QAction(u"ヘルプの表示(&H)", self)\r
+ helpmenu = self.menuBar().addMenu("ヘルプ(&H)")\r
+ tutorialact = QtGui.QAction("ヘルプの表示(&H)", self)\r
tutorialact.triggered.connect(self.tutorial_triggered)\r
tutorialact.setShortcut(QtGui.QKeySequence.HelpContents)\r
helpmenu.addAction(tutorialact)\r
- projectact = QtGui.QAction(u"プロジェクトのWebサイト(&W)", self)\r
+ projectact = QtGui.QAction("プロジェクトのWebサイト(&W)", self)\r
projectact.triggered.connect(self.project_triggered)\r
helpmenu.addAction(projectact)\r
- aboutact = QtGui.QAction(u"Pydunについて(&A)...", self)\r
+ aboutact = QtGui.QAction("Pydunについて(&A)...", self)\r
aboutact.triggered.connect(self.about_triggered)\r
helpmenu.addAction(aboutact)\r
\r
\r
def getfilename(self, filename):\r
if filename == None:\r
- s = u"無題"\r
+ s = "無題"\r
else:\r
s = os.path.splitext(os.path.basename(filename))[0]\r
return s\r
pass\r
filename = QtGui.QFileDialog.getOpenFileName(\r
dir=d,\r
- filter=u"*.pydun;;*.*", selectedFilter=u"*.pydun")\r
- if filename[0] != u"":\r
+ filter="*.pydun;;*.*", selectedFilter="*.pydun")\r
+ if filename[0] != "":\r
self.open(filename[0])\r
\r
def open(self, filename):\r
pass\r
filename = QtGui.QFileDialog.getSaveFileName(\r
dir=d,\r
- filter=u"*.pydun;;*.*", selectedFilter=u"*.pydun")\r
- if filename[0] != u"":\r
+ filter="*.pydun;;*.*", selectedFilter="*.pydun")\r
+ if filename[0] != "":\r
self.save(filename[0])\r
return True\r
else:\r
\r
@QtCore.Slot()\r
def setorigine_triggered(self):\r
- title = u"座標設定"\r
+ title = "座標設定"\r
if self.mainframe.mapframe.setoriginemode:\r
QtGui.QMessageBox.information(\r
- self, title, u"座標設定を中止します。", QtGui.QMessageBox.Ok)\r
+ self, title, "座標設定を中止します。", QtGui.QMessageBox.Ok)\r
self.mainframe.mapframe.setoriginemode = False\r
else:\r
if QtGui.QMessageBox.Ok == QtGui.QMessageBox.information(\r
- self, title, u"基準にする地点をクリックしてください。",\r
+ self, title, "基準にする地点をクリックしてください。",\r
(QtGui.QMessageBox.Ok| QtGui.QMessageBox.Cancel)):\r
self.mainframe.mapframe.setoriginemode = True\r
\r
global config\r
config["showWallMenuString"] = not config.get("showWallMenuString", False)\r
QtGui.QMessageBox.information(\r
- self, u"壁メニューに文字を表示する", u"表示の切替は再起動後に有効になります。",\r
+ self, "壁メニューに文字を表示する", "表示の切替は再起動後に有効になります。",\r
(QtGui.QMessageBox.Ok))\r
\r
@QtCore.Slot()\r
@QtCore.Slot()\r
def about_triggered(self):\r
QtGui.QMessageBox.about(self, "Pydun",\r
- u"<h1>Pydun.py "+ projectversion + "</h1>"\r
- u"<p>Copyright (c) 2013 WATAHIKI Hiroyuki</p>"\r
- u"<p>url: <a href='" + projecturl + "'>" + projecturl + "</a></p>"\r
- u"<p>e-mail: hrwatahiki at gmail.com</p>"\r
- u"<p>このソフトウェアはMITライセンスです。</p>"\r
- u"<p>このソフトウェアは以下のソフトウェアを使用しています。: "\r
- u"Python, PySide, PyYAML "\r
- u"これらの作成者に深く感謝いたします。</p>"\r
- u"<p>詳細はLICENCE.txtを参照してください。</p>")\r
+ "<h1>Pydun.py "+ projectversion + "</h1>"\r
+ "<p>Copyright (c) 2013 WATAHIKI Hiroyuki</p>"\r
+ "<p>url: <a href='" + projecturl + "'>" + projecturl + "</a></p>"\r
+ "<p>e-mail: hrwatahiki at gmail.com</p>"\r
+ "<p>twitter: <a href='https://twitter.com/hrwatahiki'>@hrwatahiki</a></p>"\r
+ "<p>blog: <a href='http://hrwatahiki.blogspot.jp/'>作業記録</a></p>"\r
+ "<p>このソフトウェアはMITライセンスです。</p>"\r
+ "<p>このソフトウェアは以下のソフトウェアを使用しています。: "\r
+ "Python, PySide, PyYAML "\r
+ "これらの作成者に深く感謝いたします。</p>"\r
+ "<p>詳細はLICENCE.txtを参照してください。</p>")\r
\r
\r
class MainFrame(QtGui.QFrame):\r
\r
self.detail = QtGui.QLabel(self)\r
self.detail.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)\r
- self.detail.setText(u"")\r
+ self.detail.setText("")\r
self.detail.setMaximumHeight(100)\r
self.detail.setMinimumHeight(100)\r
\r
self.boxdrawbutton = QtGui.QRadioButton(self)\r
- self.boxdrawbutton.setText(u"ボックス形式で壁を描画(&B)")\r
+ self.boxdrawbutton.setText("ボックス形式で壁を描画(&B)")\r
self.boxdrawbutton.setChecked(True)\r
self.boxdrawbutton.setSizePolicy(\r
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)\r
\r
self.growdrawbutton = QtGui.QRadioButton(self)\r
- self.growdrawbutton.setText(u"足跡形式で壁を描画(&G)")\r
+ self.growdrawbutton.setText("足跡形式で壁を描画(&G)")\r
self.growdrawbutton.setChecked(False)\r
self.growdrawbutton.setSizePolicy(\r
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)\r
\r
self.backcolorbutton = QtGui.QRadioButton(self)\r
- self.backcolorbutton.setText(u"背景色(&C)")\r
+ self.backcolorbutton.setText("背景色(&C)")\r
self.backcolorbutton.setChecked(False)\r
self.backcolorbutton.setSizePolicy(\r
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)\r
\r
self.setbackcolorbutton = QtGui.QPushButton(self)\r
- self.setbackcolorbutton.setText(u"背景色を設定(&S)...")\r
+ self.setbackcolorbutton.setText("背景色を設定(&S)...")\r
self.setbackcolorbutton.setSizePolicy(\r
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)\r
\r
if latestversion != projectversion:\r
self.update = QtGui.QLabel(self)\r
self.update.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)\r
- self.update.setText(u"<a href='{url}'>最新のPydun({ver})がダウンロードできます。</a>".format(url=projecturl, ver=latestversion))\r
+ self.update.setText("<a href='{url}'>最新のPydun({ver})がダウンロードできます。</a>".format(url=projecturl, ver=latestversion))\r
self.update.setOpenExternalLinks(True)\r
\r
layout = QtGui.QGridLayout(self)\r
\r
@QtCore.Slot(int, int, int)\r
def mouse_moved(self, x=0, y=0, b=QtCore.Qt.MouseButton.NoButton):\r
- cood = u"({x}, {y})\n".format(x=_mapengine.viewx(x), y=_mapengine.viewy(y))\r
+ cood = "({x}, {y})\n".format(x=_mapengine.viewx(x), y=_mapengine.viewy(y))\r
self.detail.setText(cood + _mapengine.getdetail(x, y))\r
self.mapframe.repaint()\r
\r
\r
marklabel = QtGui.QLabel(self)\r
marklabel.setAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)\r
- marklabel.setText(u"マーク(&M)")\r
+ marklabel.setText("マーク(&M)")\r
marklabel.setSizePolicy(\r
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)\r
\r
self.marktext = QtGui.QLineEdit(self)\r
self.marktext.setMaxLength(1)\r
- self.marktext.setText(u"")\r
+ self.marktext.setText("")\r
self.marktext.setMinimumWidth(20)\r
self.marktext.setSizePolicy(\r
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)\r
marklabel.setBuddy(self.marktext)\r
\r
self.forecolorbutton = QtGui.QPushButton(self)\r
- self.forecolorbutton.setText(u"文字色(&C)...")\r
+ self.forecolorbutton.setText("文字色(&C)...")\r
self.forecolorbutton.clicked.connect(self.forecolorbutton_clicked)\r
\r
self.forecolorbox = ColorBox(self)\r
\r
detaillabel = QtGui.QLabel(self)\r
detaillabel.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight)\r
- detaillabel.setText(u"詳細(&D)")\r
+ detaillabel.setText("詳細(&D)")\r
\r
self.detailtext = QtGui.QTextEdit(self)\r
- self.detailtext.setText(u"")\r
+ self.detailtext.setText("")\r
detaillabel.setBuddy(self.detailtext)\r
\r
self.buttonbox = QtGui.QDialogButtonBox(\r
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)\r
self.buttonbox.accepted.connect(self.accept)\r
self.buttonbox.rejected.connect(self.reject)\r
- self.buttonbox.button(QtGui.QDialogButtonBox.Ok).setText(u"OK")\r
- self.buttonbox.button(QtGui.QDialogButtonBox.Cancel).setText(u"キャンセル")\r
+ self.buttonbox.button(QtGui.QDialogButtonBox.Ok).setText("OK")\r
+ self.buttonbox.button(QtGui.QDialogButtonBox.Cancel).setText("キャンセル")\r
\r
layout = QtGui.QGridLayout()\r
layout.addWidget(marklabel, 0, 0, 1, 1)\r
class SetOrigineDialog(QtGui.QDialog):\r
def __init__(self, parent=None):\r
super(SetOrigineDialog, self).__init__(parent)\r
- self.setWindowTitle(u"座標設定")\r
+ self.setWindowTitle("座標設定")\r
\r
promptlabel = QtGui.QLabel(self)\r
promptlabel.setAlignment(\r
QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft)\r
- promptlabel.setText(u"この地点の座標を入力してください。")\r
+ promptlabel.setText("この地点の座標を入力してください。")\r
\r
self.currentlabel = QtGui.QLabel(self)\r
self.currentlabel.setAlignment(\r
QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter)\r
- self.currentlabel.setText(u"")\r
+ self.currentlabel.setText("")\r
\r
xlabel = QtGui.QLabel(self)\r
xlabel.setAlignment(\r
QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)\r
- xlabel.setText(u"&X")\r
+ xlabel.setText("&X")\r
\r
self.xbox = QtGui.QSpinBox(self)\r
self.xbox.setRange(-999, +999)\r
\r
ylabel = QtGui.QLabel(self)\r
ylabel.setAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)\r
- ylabel.setText(u"&Y")\r
+ ylabel.setText("&Y")\r
\r
self.ybox = QtGui.QSpinBox(self)\r
self.ybox.setRange(-999, +999)\r
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)\r
self.buttonbox.accepted.connect(self.accept)\r
self.buttonbox.rejected.connect(self.reject)\r
- self.buttonbox.button(QtGui.QDialogButtonBox.Ok).setText(u"OK")\r
- self.buttonbox.button(QtGui.QDialogButtonBox.Cancel).setText(u"キャンセル")\r
+ self.buttonbox.button(QtGui.QDialogButtonBox.Ok).setText("OK")\r
+ self.buttonbox.button(QtGui.QDialogButtonBox.Cancel).setText("キャンセル")\r
\r
layout = QtGui.QGridLayout()\r
layout.addWidget(promptlabel, 0, 0, 1, 4)\r
def setcurrent(self, x, y):\r
self.xbox.setValue(x)\r
self.ybox.setValue(y)\r
- self.currentlabel.setText(u"現在の座標 ({x}, {y})".format(x=x, y=y))\r
+ self.currentlabel.setText("現在の座標 ({x}, {y})".format(x=x, y=y))\r
\r
@property\r
def originex(self):\r
class SetSizeDialog(QtGui.QDialog):\r
def __init__(self, parent=None):\r
super(SetSizeDialog, self).__init__(parent)\r
- self.setWindowTitle(u"マップのサイズ")\r
+ self.setWindowTitle("マップのサイズ")\r
\r
self.topbutton = QtGui.QRadioButton(self)\r
- self.topbutton.setText(u"上(&T)")\r
+ self.topbutton.setText("上(&T)")\r
self.topbutton.clicked.connect(self.updatewidgets)\r
\r
self.topsize = QtGui.QSpinBox(self)\r
self.topsize.valueChanged.connect(self.updatewidgets)\r
\r
self.bottombutton = QtGui.QRadioButton(self)\r
- self.bottombutton.setText(u"下(&B)")\r
+ self.bottombutton.setText("下(&B)")\r
self.bottombutton.clicked.connect(self.updatewidgets)\r
\r
self.bottomsize = QtGui.QSpinBox(self)\r
self.bottomsize.valueChanged.connect(self.updatewidgets)\r
\r
self.leftbutton = QtGui.QRadioButton(self)\r
- self.leftbutton.setText(u"左(&L)")\r
+ self.leftbutton.setText("左(&L)")\r
self.leftbutton.clicked.connect(self.updatewidgets)\r
\r
self.leftsize = QtGui.QSpinBox(self)\r
self.leftsize.valueChanged.connect(self.updatewidgets)\r
\r
self.rightbutton = QtGui.QRadioButton(self)\r
- self.rightbutton.setText(u"右(&R)")\r
+ self.rightbutton.setText("右(&R)")\r
self.rightbutton.clicked.connect(self.updatewidgets)\r
\r
self.rightsize = QtGui.QSpinBox(self)\r
self.sizelabel = QtGui.QLabel(self)\r
self.sizelabel .setAlignment(\r
QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft)\r
- self.sizelabel.setText(u"この地点の座標を入力してください。")\r
+ self.sizelabel.setText("この地点の座標を入力してください。")\r
\r
self.buttonbox = QtGui.QDialogButtonBox(\r
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)\r
self.buttonbox.accepted.connect(self.accept)\r
self.buttonbox.rejected.connect(self.reject)\r
- self.buttonbox.button(QtGui.QDialogButtonBox.Ok).setText(u"OK")\r
- self.buttonbox.button(QtGui.QDialogButtonBox.Cancel).setText(u"キャンセル")\r
+ self.buttonbox.button(QtGui.QDialogButtonBox.Ok).setText("OK")\r
+ self.buttonbox.button(QtGui.QDialogButtonBox.Cancel).setText("キャンセル")\r
\r
verticalgroup = QtGui.QButtonGroup(self)\r
verticalgroup.addButton(self.topbutton)\r
self.rightsize.setEnabled(True)\r
\r
self.sizelabel.setText(\r
- u"変更前のサイズ: {w1} x {h1}\n変更後のサイズ: {w2} x {h2}".format(\r
+ "変更前のサイズ: {w1} x {h1}\n変更後のサイズ: {w2} x {h2}".format(\r
w1=self._width, h1=self._height,\r
w2=self._width+dw, h2=self._height+dh))\r
\r
class MapImages(object):\r
def __init__(self, show_wall_menu_string):\r
if show_wall_menu_string:\r
- vtext = [u"なし", u"壁", u"扉", u"扉(→)", u"扉(←)", u"一通(→)", u"一通(←)", u"隠", u"隠(→)", u"隠(←)",]\r
- htext = [u"なし", u"壁", u"扉", u"扉(↓)", u"扉(↑)", u"一通(↓)", u"一通(↑)", u"隠", u"隠(↓)", u"隠(↑)",]\r
+ vtext = ["なし", "壁", "扉", "扉(→)", "扉(←)", "一通(→)", "一通(←)", "隠", "隠(→)", "隠(←)",]\r
+ htext = ["なし", "壁", "扉", "扉(↓)", "扉(↑)", "一通(↓)", "一通(↑)", "隠", "隠(↓)", "隠(↑)",]\r
else:\r
- vtext = [u"", u"", u"", u"", u"", u"", u"", u"", u"", u"",]\r
- htext = [u"", u"", u"", u"", u"", u"", u"", u"", u"", u"",]\r
+ vtext = ["", "", "", "", "", "", "", "", "", "",]\r
+ htext = ["", "", "", "", "", "", "", "", "", "",]\r
self.wall_images = list()\r
self.wall_icons = list()\r
self.wall_texts = list()\r
for direction in ["v", "h"]:\r
filename = os.path.join(\r
basedir(),\r
- u"images",\r
- u"wall_{direction}_{index:02}.png".format(\r
+ "images",\r
+ "wall_{direction}_{index:02}.png".format(\r
direction=direction, index=index))\r
self.wall_images[index][direction] = QtGui.QImage()\r
self.wall_images[index][direction].load(filename)\r
def represent_unicode(dumper, data):\r
return dumper.represent_scalar("tag:yaml.org,2002:str", data)\r
def construct_unicode(loader, node):\r
- return unicode(loader.construct_scalar(node))\r
- yaml.add_representer(unicode, represent_unicode)\r
+ return str(loader.construct_scalar(node))\r
+ yaml.add_representer(str, represent_unicode)\r
yaml.add_constructor("tag:yaml.org,2002:str", construct_unicode)\r
\r
def getdata(self, x, y, direction):\r
\r
def getnote(self, x, y):\r
return self._note.get(\r
- self.coodtokey(x, y), {"mark":u"", "detail":u"", "forecolor":u"#000000", "backcolor":u""})\r
+ self.coodtokey(x, y), {"mark":"", "detail":"", "forecolor":"#000000", "backcolor":""})\r
\r
def coodtokey(self, x, y):\r
- return u"{x:+05d}_{y:+05d}".format(x=x, y=y)\r
+ return "{x:+05d}_{y:+05d}".format(x=int(x), y=int(y))\r
\r
def keytocood(self, key):\r
- return map(int, key.split("_"))\r
+ return list(map(int, key.split("_")))\r
\r
def setmark(self, x, y, mark):\r
note = self.getnote(x, y)\r
\r
def save(self, filename):\r
dt = self.savestring()\r
- with codecs.open(filename, "w") as f:\r
+ with open(filename, "w", encoding='utf-8') as f:\r
f.write(dt)\r
self.filename = filename\r
\r
\r
#noteは表示用に座標変換する。\r
n = dict()\r
- for nk, ni in self._note.items():\r
+ for nk, ni in list(self._note.items()):\r
if ni["mark"] != "" or ni["detail"] != "" or ni["backcolor"]:\r
x, y = self.keytocood(nk)\r
n[self.coodtokey(self.viewx(x), self.viewy(y))] = ni\r
data["note"] = n\r
return yaml.safe_dump(data, allow_unicode=True,\r
- default_flow_style=False, encoding='utf-8')\r
+ default_flow_style=False, encoding='utf-8').decode('utf-8')\r
\r
def getmapstring(self):\r
#出力用マップ作成\r
return m\r
\r
def load(self, filename):\r
- with codecs.open(filename, "r", encoding="utf-8") as f:\r
+ with open(filename, "r", encoding="utf-8") as f:\r
st = f.read()\r
self.loadfromstring(st)\r
self.filename = filename\r
\r
#noteは内部用に座標変換する。\r
n = dict()\r
- for nk, ni in data["note"].items():\r
+ for nk, ni in list(data["note"].items()):\r
if ni["mark"] != "" or ni["detail"] != "" or ni["backcolor"] != "":\r
x, y = self.keytocood(nk)\r
n[self.coodtokey(self.worldx(x), self.worldy(y))] = ni\r
class PydunAskSaveDialog(QtGui.QMessageBox):\r
def __init__(self, parent, filename):\r
super(PydunAskSaveDialog, self).__init__(parent)\r
- self.setText(u"{filename} への変更を保存しますか?".format(filename=filename))\r
+ self.setText("{filename} への変更を保存しますか?".format(filename=filename))\r
self.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)\r
self.setDefaultButton(QtGui.QMessageBox.Save)\r
- self.button(QtGui.QMessageBox.Save).setText(u"保存する(&S)")\r
- self.button(QtGui.QMessageBox.Discard).setText(u"保存しない(&N)")\r
- self.button(QtGui.QMessageBox.Cancel).setText(u"キャンセル")\r
+ self.button(QtGui.QMessageBox.Save).setText("保存する(&S)")\r
+ self.button(QtGui.QMessageBox.Discard).setText("保存しない(&N)")\r
+ self.button(QtGui.QMessageBox.Cancel).setText("キャンセル")\r
\r
\r
def getcolorstring(color):\r
int(colorstring[5:7], 16))\r
\r
def basedir():\r
- return os.path.dirname(os.path.abspath(unicode(sys.argv[0], locale.getpreferredencoding())))\r
+ return os.path.dirname(os.path.abspath(sys.argv[0]))\r
\r
def getlatestversion():\r
try:\r
- rss = urllib.urlopen(projectrssurl)\r
+ rss = urllib.request.urlopen(projectrssurl)\r
rssstring = rss.read()\r
rsstree = xml.etree.ElementTree.fromstring(rssstring)\r
item = rsstree.find("channel/item/title")\r
global configfilename\r
configfilename = os.path.join(\r
basedir(),\r
- u"Pydun.config")\r
+ "Pydun.config")\r
try:\r
with open(configfilename, "r") as f:\r
config = yaml.safe_load(f)\r