【转载】geany linux python编译器 开源

http://www.dekiru.cn/?p=1491

Geany 不好用,建议用一些好用的编辑器或ide

Subliem Text 或 VS code

Pycharm等。

设置运行环境

菜单栏–生成–设置生成命令–执行命令(execute)那里输入python3 %f

以后直接按F5键即可运行python文件.

设置代码检查

配置pep8

菜单栏–生成–设置生成命令–Lint–输入pep8 –max-line-length=80 "%f"

sudo pip3 install pep8

或者使用最新的pycodestyle进行代码检测.

sudo pip3 install pycodestyle

使用pep8

菜单栏–生成–Lint

使用空格代替制表符

菜单栏–编辑–首选项–编辑器–缩进–宽度:4,类型:空格,勾上"用Tab键缩进"

菜单栏–编辑–首选项–文件–保存文件–用空格替换制表符

代码格式化

使用black或着autopep8.

配置black或autopep8

sudo pip3 install black

sudo pip3 install autopep8

菜单栏–生成–设置生成命令–python命令部分–新增命令项:格式化python文件,black %f

菜单栏–生成–设置生成命令–python命令部分–新增命令项:格式化python文件,autopep8 -i %f

black使用方法

菜单栏–生成–格式化python文件,或者直接按F9格式化.

然后ctrl+r重新载入格式化的文件即可.

自动完成

配置snippets

菜单栏–工具–配置文件–snippets.conf,或者直接修改 ~/.config/geany/snippets.conf

官网来源https://wiki.geany.org/snippets/python/start

[Special]部分新增

wordchars=._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

[Python]部分新增

for=for i in xrange(%cursor%):
doc=""" %cursor% """
elif=elif %cursor%:
else=else: %cursor%
if=if %cursor%:
from=from %cursor% import
main=if __name__ == '__main__': %cursor%
class=class %cursor%(object): """ Class doc """ def __init__ (self): """ Class initialiser """ pass
def=def %cursor%(self): """ Function doc @param PARAM: DESCRIPTION @return RETURN: DESCRIPTION """
get=def get%cursor%(self): return self._var
set=def set%cursor%(self): self._var = var
.=self.%cursor%
prop=property %cursor%: def __get__(self): return self.%cursor%_get() def __set__(self, value): self.%cursor%_set(value)
try=try: %cursor% except Exception, e:
py=#!/usr/bin/env python #-*- coding:utf-8 -*- %cursor%
while=while %cursor%:
with=with %cursor%:
head=""" %cursor%PROJECT – MODULE DESCRIPTION @copyright: {year} by {developer} <{mail}> @license: GNU GPL, see COPYING for details. """
pp=from pprint import pprint pprint(%cursor%)
cod=# coding: utf-8
dt=from datetime import datetime

使用方法,输入main,按tab,geany自动将main补全为if __name__ == '__main__':

代码提示

配置tag

官网下载tag文件https://wiki.geany.org/tags/start

解压后,把tag后缀的文件方法到~/.config/geany/tag目录即可

安装插件

配置插件:菜单栏–工具–插件管理器–勾选插件–点击窗口低下的配置按钮

官网地址:https://plugins.geany.org/

文件浏览器:sudo apt-get install geany-plugin-treebrowser

成对标签高亮:geany-plugin-pairtaghighlighter

自动高亮相同的字符:geany-plugin-automark

代码缩略图:geany-plugin-overview

虚拟终端支持:geany-plugin-multiterm

markdown支持:geany-plugin-markdown

python支持:geany-plugin-py(Provides most of the standard Geany C API for Python,该插件可以让geany支持python写的插件,比如geany pynav,也可以自己用python为geany写插件.)

xml美化:geany-plugin-prettyprinter

在实现和接口间跳转:geany-plugin-codenav

其他的小附加组件:geany-plugin-addons

在终端执行程序

菜单栏–编辑–首选项–虚拟终端–勾选“在虚拟终端中执行程序”

geany的插件文档

https://www.geany.org/manual/reference/index.html

配置pip国内的一些镜像

  阿里云 https://mirrors.aliyun.com/pypi/simple/
  中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  豆瓣(douban) http://pypi.douban.com/simple/
  清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
  中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
 ~/.pip/pip.conf 

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

原文地址:https://www.cnblogs.com/xuanbjut/p/11260451.html